public ConvergeTriggeredAbilitySpec(JSONTable template, ContentManager Content) { triggerType = (ConvergeTriggerType)Enum.Parse(typeof(ConvergeTriggerType), template.getString("trigger")); triggerPlayer = ConvergeSelector.New(template.getProperty("triggerPlayer", null)); triggerSubject = ConvergeSelector.New(template.getProperty("triggerSubject", null)); triggerTarget = ConvergeSelector.New(template.getProperty("triggerTarget", null)); condition = ConvergeSelector.New(template.getProperty("condition", null)); effect = ConvergeCommand.New(template.getArray("effect"), Content); }
public void Init(JSONTable template, ContentManager Content) { string artName = template.getString("art"); art = Content.Load <Texture2D>(artName); name = template.getString("name", artName); // for now text = template.getString("text", "").InsertLineBreaks(Game1.font, ConvergeUIObject.CardTooltipWidth - 15); textHeight = (int)Game1.font.MeasureString(text).Y; cardType = 0; foreach (string name in template.getArray("cardType").asStrings()) { cardType |= (ConvergeCardType)Enum.Parse(typeof(ConvergeCardType), name); } power = template.getInt("power", 0); toughness = template.getInt("toughness", 0); string producesTemplate = template.getString("produces", ""); if (producesTemplate != "") { produces = new ConvergeManaAmount(template.getString("produces")); } string costTemplate = template.getString("cost", ""); if (costTemplate != "") { cost = new ConvergeManaAmount(costTemplate); } keywords = 0; foreach (string name in template.getArray("keywords", JSONArray.empty).asStrings()) { keywords |= (ConvergeKeyword)Enum.Parse(typeof(ConvergeKeyword), name); } activatedAbilities = new List <ConvergeActivatedAbilitySpec>(); foreach (JSONTable abilityTemplate in template.getArray("activated", JSONArray.empty).asJSONTables()) { activatedAbilities.Add(new ConvergeActivatedAbilitySpec(abilityTemplate, Content)); } triggeredAbilities = new List <ConvergeTriggeredAbilitySpec>(); foreach (JSONTable abilityTemplate in template.getArray("triggered", JSONArray.empty).asJSONTables()) { triggeredAbilities.Add(new ConvergeTriggeredAbilitySpec(abilityTemplate, Content)); } if (template.hasKey("effect")) { actionEffect = ConvergeCommand.New(template.getArray("effect"), Content); } if (template.hasKey("target")) { actionTarget = ConvergeSelector.New(template.getProperty("target")); } }
public ConvergeActivatedAbilitySpec(JSONTable template, ContentManager Content) { frame = Content.Load <Texture2D>(template.getString("frame", "abilityFrame")); icon = Content.Load <Texture2D>(template.getString("icon")); text = template.getString("text", "").InsertLineBreaks(Game1.font, ConvergeUIAbility.AbilityTooltipWidth - 15); textHeight = (int)Game1.font.MeasureString(text).Y; effect = ConvergeCommand.New(template.getArray("effect"), Content); frameColor = template.getString("frameColor", "FFFFFF").toColor(); if (template.hasKey("attackEffect")) { attackEffect = ConvergeCommand.New(template.getArray("attackEffect"), Content); } if (template.hasKey("target")) { target = ConvergeSelector.New(template.getProperty("target")); } manacost = new ConvergeManaAmount(template.getString("manaCost", "")); uses = template.getInt("uses", 0); altCost = 0; foreach (string altcostString in template.getArray("altCost", JSONArray.empty).asStrings()) { altCost |= (ConvergeAltCost)Enum.Parse(typeof(ConvergeAltCost), altcostString); } JSONArray zoneTemplate = template.getArray("activeZones", null); if (zoneTemplate == null) { activeZones = ConvergeZoneId.Attack | ConvergeZoneId.Defense | ConvergeZoneId.Home; } else { activeZones = 0; foreach (string zoneName in zoneTemplate.asStrings()) { activeZones |= (ConvergeZoneId)Enum.Parse(typeof(ConvergeZoneId), zoneName); } } }