コード例 #1
0
        public Card(JSONTable template, ContentManager content)
        {
            name = template.getString("name");
            cost = ResourceAmount.createList(template.getJSON("cost", null));
            effect = Effect_Base.create(template.getArray("effect", null));
            if (template.hasKey("ongoing") || template.hasKey("triggers"))
            {
                ongoingType = new PermanentType(template, content);
            }
            image = content.Load<Texture2D>(template.getString("texture"));
            smallFrameTexture = content.Load<Texture2D>("square");
            Enum.TryParse<TargetType>(template.getString("target", "none"), out targetType);
            frameTexture = content.Load<Texture2D>("cardframe_large");
            description = DragonGfx.Tooltip.StringToLines(template.getString("description", ""), Game1.font, 100);
            upgradeCost = ResourceAmount.createList(template.getJSON("upgradeCost", null));
            targetTest = TriggerItemTest.create(template.getArray("targetTest", null));
            spellSet = template.getString("spellSet", null);

            foreach (JSONTable upgradeTemplate in template.getArray("upgrades", JSONArray.empty).asJSONTables())
            {
                if(upgrades == null)
                    upgrades = new List<Card>();

                upgrades.Add(new Card(upgradeTemplate, content));
            }

            switch (template.getString("type", null))
            {
                case "special":
                    frameColor = new Color(235, 200, 255);
                    break;
                case "minion":
                    frameColor = new Color(200, 255, 200);
                    break;
                case "production":
                    frameColor = new Color(255, 220, 190);
                    break;
                case "modifier":
                    frameColor = new Color(255, 190, 200);
                    break;
                default:
                    frameColor = Color.White;
                    break;
            }

            string id = template.getString("id", null);
            if (id != null)
            {
                cardsById.Add(id, this);
            }

            defaultUnlocked = template.getBool("unlocked", false);
            unlocked = defaultUnlocked;
        }
コード例 #2
0
        public TriggeredAbility(JSONArray template)
        {
            if (!Enum.TryParse<TriggerType>(template.getString(0), out type))
                throw new ArgumentException("Unknown trigger type " + template.getString(0));

            if(template.Length > 2)
                sourceTest = TriggerItemTest.create(template, 1);
            if(template.Length > 3)
                targetTest = TriggerItemTest.create(template, 2);

            effect = Effect_Base.createSingle(template.getArray(template.Length - 1));
            if (template.Length > 4)
            {
                isAttackTrigger = template.getBool(3);
            }
        }
コード例 #3
0
 public List<Minion> getMinions(TriggerItemTest test, EffectContext context)
 {
     List<Minion> result = new List<Minion>();
     foreach (KeyValuePair<Point, Minion> kv in minions)
     {
         if (test.Test(TriggerItem.create(kv.Value), context))
         {
             result.Add(kv.Value);
         }
     }
     return result;
 }
コード例 #4
0
 public Property_Count(JSONArray template)
 {
     this.test = TriggerItemTest.create(template);
 }