Opened 9 years ago

Closed 9 years ago

Last modified 9 years ago

#320 closed enhancement (fixed)

WarFoundry.API - GameSystem cannot remove or set categories and stat lines

Reported by: Tsudico Owned by: Tsudico
Priority: major Milestone: WarFoundry API 0.2
Component: WarFoundry-API Version: Trunk
Keywords: Cc:
Blocked By: Blocking:

Description

In order to continue to use the API for WarFoundry Forge, GameSystem needs to include both a way to remove or set categories and stat lines. I don't think I can upload a commit to the API directory so I am putting example code here:

Remove Category

public void RemoveCategory(string id)
{
	RawCategories.Remove(id);
}

Set Category(have not verified if this works as expected)

public void SetCategory(Category cat)
{
	Category old;
	RawCategories.TryGetValue(cat.ID, out old);
	if(old == null)
	{
		AddCategory(cat);
	}
	else if(!old.Equals(cat))
	{
		RawCategories[cat.ID] = cat;
	}
}

The same can be done for System Stats like the above.

public void SetSystemStats(SystemStats newStats)
{
	SystemStats old;
	stats.TryGetValue(newStats.ID, out old);
	if(old == null)
	{
		AddSystemStats(newStats);
	}
	else if(!old.Equals(newStats))
	{
		stats[old.ID] = newStats;
	}
}
		
public void RemoveSystemStats(string id)
{
	stats.Remove(id);
}

Change History (5)

comment:1 Changed 9 years ago by ibboard

Status: newconfirmed

Sorry, I'll add you to the main WF repo as well - I must have just added you to the Mercurial section.

Remove methods seem sensible - I'd avoided them as a) they weren't necessary and b) they stopped people tinkering with things in code once they were loaded (to a degree). a) is now void, as you need them, and b) was kinda void since there are still other things that you can do anyway.

comment:2 Changed 9 years ago by Tsudico

Owner: set to Tsudico
Status: confirmedaccepted

comment:3 Changed 9 years ago by Tsudico

In [730]:

Re #320: WarFoundry.API - GameSystem cannot remove or set categories and stat lines

  • Update GameSystem
    • Categories
      • SetCategory added
      • RemoveCategory added
    • SystemStats
      • SetSystemStats added
      • RemoveSystemStats added

comment:4 Changed 9 years ago by Tsudico

Resolution: fixed
Status: acceptedclosed

comment:5 Changed 9 years ago by ibboard

Milestone: WarFoundry 0.2WarFoundry API 0.2

Separate API milestone from UI milestone

Note: See TracTickets for help on using tickets.