コード例 #1
0
        public virtual string ToSaveString(bool readable)
        {
            StringBuilder sb = new StringBuilder();

            if (!this.isEnabled())
            {
                sb.Append(";");
            }
            if (this is GenericCondition)
            {
                SaveableItem[] parts = ((GenericCondition)this).getUsefulDefinitionParts();
                sb.Append(((GenericCondition)this).Name + "(");
                for (int i = 0; i < parts.Length; i++)
                {
                    SaveableItem part = parts[i];
                    sb.Append(part.ToSaveString(readable));
                    if (i != parts.Length - 1)
                    {
                        sb.Append(", ");
                    }
                }
                sb.Append(");");
            }
            else if (this is EPDCondition)
            {
                EPDCondition epd = (EPDCondition)this;
                sb.Append(epd.ToString());
            }
            else
            {
                throw new NotImplementedException();
            }
            return(sb.ToString());
        }
コード例 #2
0
        private List <ConstrucableTrigger> getConditionTemplates()
        {
            List <ConstrucableTrigger> lst = new List <ConstrucableTrigger>();

            lst.Add(new ConstrucableTriggerTemplate("Accumulate", () => new ConditionAccumulate(new WeakParser(ConditionAccumulate.getComponents(), ConditionAccumulate.getTextMapping()))));
            lst.Add(new ConstrucableTriggerTemplate("Always", () => new ConditionAlways(new WeakParser(ConditionAlways.getComponents(), ConditionAlways.getTextMapping()))));
            lst.Add(new ConstrucableTriggerTemplate("Bring", () => new ConditionBring(new WeakParser(ConditionBring.getComponents(), ConditionBring.getTextMapping()))));
            lst.Add(new ConstrucableTriggerTemplate("Commands", () => new ConditionCommand(new WeakParser(ConditionCommand.getComponents(), ConditionCommand.getTextMapping()))));
            lst.Add(new ConstrucableTriggerTemplate("Commands The Least", () => new ConditionCommandTheLeast(new WeakParser(ConditionCommandTheLeast.getComponents(), ConditionCommandTheLeast.getTextMapping()))));
            lst.Add(new ConstrucableTriggerTemplate("Commands The Least At", () => new ConditionCommandTheLeastAt(new WeakParser(ConditionCommandTheLeastAt.getComponents(), ConditionCommandTheLeastAt.getTextMapping()))));
            lst.Add(new ConstrucableTriggerTemplate("Commands The Most", () => new ConditionCommandTheMost(new WeakParser(ConditionCommandTheMost.getComponents(), ConditionCommandTheMost.getTextMapping()))));
            lst.Add(new ConstrucableTriggerTemplate("Commands The Most At", () => new ConditionCommandsTheMostAt(new WeakParser(ConditionCommandsTheMostAt.getComponents(), ConditionCommandsTheMostAt.getTextMapping()))));
            lst.Add(new ConstrucableTriggerTemplate("Countdown Timer", () => new ConditionCountdownTimer(new WeakParser(ConditionCountdownTimer.getComponents(), ConditionCountdownTimer.getTextMapping()))));
            lst.Add(new ConstrucableTriggerTemplate("Deaths", () => new ConditionDeaths(new WeakParser(ConditionDeaths.getComponents(), ConditionDeaths.getTextMapping()))));
            lst.Add(new ConstrucableTriggerTemplate("Elapsed Time", () => new ConditionElapsedTime(new WeakParser(ConditionElapsedTime.getComponents(), ConditionElapsedTime.getTextMapping()))));
            lst.Add(new ConstrucableTriggerTemplate("Highes tScore", () => new ConditionHighestScore(new WeakParser(ConditionHighestScore.getComponents(), ConditionHighestScore.getTextMapping()))));
            lst.Add(new ConstrucableTriggerTemplate("Kill", () => new ConditionKill(new WeakParser(ConditionKill.getComponents(), ConditionKill.getTextMapping()))));
            lst.Add(new ConstrucableTriggerTemplate("Least Kills", () => new ConditionLeastKills(new WeakParser(ConditionLeastKills.getComponents(), ConditionLeastKills.getTextMapping()))));
            lst.Add(new ConstrucableTriggerTemplate("Least Resources", () => new ConditionLeastResources(new WeakParser(ConditionLeastResources.getComponents(), ConditionLeastResources.getTextMapping()))));
            lst.Add(new ConstrucableTriggerTemplate("Lowest Score", () => new ConditionLowestScore(new WeakParser(ConditionLowestScore.getComponents(), ConditionLowestScore.getTextMapping()))));
            lst.Add(new ConstrucableTriggerTemplate("Most Kills", () => new ConditionMostKills(new WeakParser(ConditionMostKills.getComponents(), ConditionMostKills.getTextMapping()))));
            lst.Add(new ConstrucableTriggerTemplate("Most Resources", () => new ConditionMostResources(new WeakParser(ConditionMostResources.getComponents(), ConditionMostResources.getTextMapping()))));
            lst.Add(new ConstrucableTriggerTemplate("Never", () => new ConditionNever(new WeakParser(ConditionNever.getComponents(), ConditionNever.getTextMapping()))));
            lst.Add(new ConstrucableTriggerTemplate("Opponents", () => new ConditionOpponents(new WeakParser(ConditionOpponents.getComponents(), ConditionOpponents.getTextMapping()))));
            lst.Add(new ConstrucableTriggerTemplate("Score", () => new ConditionScore(new WeakParser(ConditionScore.getComponents(), ConditionScore.getTextMapping()))));
            lst.Add(new ConstrucableTriggerTemplate("Switch", () => new ConditionSwitch(new WeakParser(ConditionSwitch.getComponents(), ConditionSwitch.getTextMapping()))));
            lst.Add(new ConstrucableTriggerTemplate("Memory", () => new ConditionMemory(new WeakParser(ConditionMemory.getComponents(), ConditionMemory.getTextMapping()))));
            EPDCondition.fillConstructables(lst);
            return(lst);
        }
コード例 #3
0
        private Condition GetCondition(CommandToken ct)
        {
            int position = ct.getPosition();

            if (ct.isAccumulate())
            {
                return(new ConditionAccumulate(this));
            }
            else if (ct.isAlways())
            {
                return(new ConditionAlways(this));
            }
            else if (ct.isBring())
            {
                return(new ConditionBring(this));
            }
            else if (ct.isCommand())
            {
                return(new ConditionCommand(this));
            }
            else if (ct.isCommandTheLeast())
            {
                return(new ConditionCommandTheLeast(this));
            }
            else if (ct.isCommandTheLeastAt())
            {
                return(new ConditionCommandTheLeastAt(this));
            }
            else if (ct.isCommandTheMost())
            {
                return(new ConditionCommandTheMost(this));
            }
            else if (ct.isCommandsTheMostAt())
            {
                return(new ConditionCommandsTheMostAt(this));
            }
            else if (ct.isCountdownTimer())
            {
                return(new ConditionCountdownTimer(this));
            }
            else if (ct.isDeaths())
            {
                ConditionDeaths d      = new ConditionDeaths(this);
                UnitVanillaDef  unit   = d.getUnitDef();
                PlayerDef       player = d.getPlayerDef();
                IntDef          amount = d.getAmount();
                Quantifier      q      = d.getQuantifier();
                if (unit.getIndex() > unit.getMaxValue())   // EUD Condition
                {
                    int pid  = player.getIndex();
                    int uid  = unit.getIndex();
                    int oid  = amount.getIndex();
                    int addr = (uid * 12) + pid;

                    ConditionMemory cm   = new ConditionMemory(new DummyParser(new Token[] { new LeftBracket(position), new NumToken(addr.ToString(), position), new Comma(position), new CommandToken(q.ToString(), position), new Comma(position), new NumToken(oid.ToString(), position), new RightBracket(position) }));
                    EPDCondition    cond = EPDCondition.get(cm);
                    if (cond != null)
                    {
                        return(cond);
                    }

                    return(cm);
                }

                return(d);
            }
            else if (ct.isElapsedTime())
            {
                return(new ConditionElapsedTime(this));
            }
            else if (ct.isHighestScore())
            {
                return(new ConditionHighestScore(this));
            }
            else if (ct.isKill())
            {
                return(new ConditionKill(this));
            }
            else if (ct.isLeastKills())
            {
                return(new ConditionLeastKills(this));
            }
            else if (ct.isLeastResources())
            {
                return(new ConditionLeastResources(this));
            }
            else if (ct.isLowestScore())
            {
                return(new ConditionLowestScore(this));
            }
            else if (ct.isMostKills())
            {
                return(new ConditionMostKills(this));
            }
            else if (ct.isMostResources())
            {
                return(new ConditionMostResources(this));
            }
            else if (ct.isNever())
            {
                return(new ConditionNever(this));
            }
            else if (ct.isOpponents())
            {
                return(new ConditionOpponents(this));
            }
            else if (ct.isScore())
            {
                return(new ConditionScore(this));
            }
            else if (ct.isSwitch())
            {
                return(new ConditionSwitch(this));
            }
            else if (ct.isMemory())
            {
                ConditionMemory cm   = new ConditionMemory(this);
                EPDCondition    cond = EPDCondition.get(cm);
                if (cond != null)
                {
                    return(cond);
                }
                return(cm);
            }
            else if (ct.isCustom())
            {
                return(new ConditionCustom(this));
            }
            throw new NotImplementedException();
        }