Exemple #1
0
 private Action getAction(CommandToken ct)
 {
     if (ct.isCenterView())
     {
         return(new ActionCenterView(this));
     }
     else if (ct.isComment())
     {
         return(new ActionComment(this));
     }
     else if (ct.isCreateUnit())
     {
         return(new ActionCreateUnit(this));
     }
     else if (ct.isCreateUnitWithProperties())
     {
         return(new ActionCreateUnitWithProperties(this));
     }
     else if (ct.isDefeat())
     {
         return(new ActionDefeat(this));
     }
     else if (ct.isDisplayTextMessage())
     {
         return(new ActionDisplayTextMessage(this));
     }
     else if (ct.isDraw())
     {
         return(new ActionDraw(this));
     }
     else if (ct.isGiveUnitsToPlayer())
     {
         return(new ActionGiveUnitsToPlayer(this));
     }
     else if (ct.isKillUnit())
     {
         return(new ActionKillUnit(this));
     }
     else if (ct.isKillUnitAtLocation())
     {
         return(new ActionKillUnitAtLocation(this));
     }
     else if (ct.isLeaderBoardControlAtLocation())
     {
         return(new ActionLeaderBoardControlAtLocation(this));
     }
     else if (ct.isLeaderBoardControl())
     {
         return(new ActionLeaderBoardControl(this));
     }
     else if (ct.isLeaderboardGreed())
     {
         return(new ActionLeaderboardGreed(this));
     }
     else if (ct.isLeaderBoardKills())
     {
         ActionLeaderBoardKills act = new ActionLeaderBoardKills(this);
         int[]          mapping     = ActionLeaderBoardKills.getTextMapping();
         int            unitIndex   = mapping[0];
         UnitVanillaDef unit        = act.get <UnitVanillaDef>(unitIndex);
         if (unit.getIndex() > unit.getMaxValue())
         {
             return(new ActionLeaderBoardDeaths(act));
         }
         return(act);
     }
     else if (ct.isLeaderBoardPoints())
     {
         return(new ActionLeaderBoardPoints(this));
     }
     else if (ct.isLeaderBoardResources())
     {
         return(new ActionLeaderBoardResources(this));
     }
     else if (ct.isLeaderboardComputerPlayers())
     {
         return(new ActionLeaderboardComputerPlayers(this));
     }
     else if (ct.isLeaderboardGoalControlAtLocation())
     {
         return(new ActionLeaderboardGoalControlAtLocation(this));
     }
     else if (ct.isLeaderboardGoalControl())
     {
         return(new ActionLeaderboardGoalControl(this));
     }
     else if (ct.isLeaderboardGoalKills())
     {
         return(new ActionLeaderboardGoalKills(this));
     }
     else if (ct.isLeaderboardGoalPoints())
     {
         return(new ActionLeaderboardGoalPoints(this));
     }
     else if (ct.isLeaderboardGoalResources())
     {
         return(new ActionLeaderboardGoalResources(this));
     }
     else if (ct.isMinimapPing())
     {
         return(new ActionMinimapPing(this));
     }
     else if (ct.isModifyUnitEnergy())
     {
         return(new ActionModifyUnitEnergy(this));
     }
     else if (ct.isModifyUnitHangerCount())
     {
         return(new ActionModifyUnitHangerCount(this));
     }
     else if (ct.isModifyUnitHitPoints())
     {
         return(new ActionModifyUnitHitPoints(this));
     }
     else if (ct.isModifyUnitResourceAmount())
     {
         return(new ActionModifyUnitResourceAmount(this));
     }
     else if (ct.isModifyUnitShieldPoints())
     {
         return(new ActionModifyUnitShieldPoints(this));
     }
     else if (ct.isMoveLocation())
     {
         return(new ActionMoveLocation(this));
     }
     else if (ct.isPlayWAV())
     {
         return(new ActionPlayWAV(this));
     }
     else if (ct.isMoveUnit())
     {
         return(new ActionMoveUnit(this));
     }
     else if (ct.isMuteUnitSpeech())
     {
         return(new ActionMuteUnitSpeech(this));
     }
     else if (ct.isOrder())
     {
         return(new ActionOrder(this));
     }
     else if (ct.isPauseGame())
     {
         return(new ActionPauseGame(this));
     }
     else if (ct.isPauseTimer())
     {
         return(new ActionPauseTimer(this));
     }
     else if (ct.isPreserveTrigger())
     {
         return(new ActionPreserveTrigger(this));
     }
     else if (ct.isRemoveUnit())
     {
         return(new ActionRemoveUnit(this));
     }
     else if (ct.isRemoveUnitAtLocation())
     {
         return(new ActionRemoveUnitAtLocation(this));
     }
     else if (ct.isRunAIScript())
     {
         return(new ActionRunAIScript(this));
     }
     else if (ct.isRunAIScriptAtLocation())
     {
         return(new ActionRunAIScriptAtLocation(this));
     }
     else if (ct.isSetAllianceStatus())
     {
         return(new ActionSetAllianceStatus(this));
     }
     else if (ct.isSetCountdownTimer())
     {
         return(new ActionSetCountdownTimer(this));
     }
     else if (ct.isSetDeaths())
     {
         RawActionSetDeaths rawDeaths = new RawActionSetDeaths(this);
         Action             epd       = EPDAction.getFromDeathAction(rawDeaths);
         if (epd != null)
         {
             return(epd);
         }
         else
         {
             try {
                 return(new ActionSetDeaths(rawDeaths));
             } catch (NotImplementedException) {
                 return(rawDeaths);
             }
             //return rawDeaths;
         }
     }
     else if (ct.isSetDoodadState())
     {
         return(new ActionSetDoodadState(this));
     }
     else if (ct.isSetInvincibility())
     {
         return(new ActionSetInvincibility(this));
     }
     else if (ct.isSetMissionObjectives())
     {
         return(new ActionSetMissionObjectives(this));
     }
     else if (ct.isSetNextScenario())
     {
         return(new ActionSetNextScenario(this));
     }
     else if (ct.isSetResources())
     {
         return(new ActionSetResources(this));
     }
     else if (ct.isSetScore())
     {
         return(new ActionSetScore(this));
     }
     else if (ct.isSetSwitch())
     {
         return(new ActionSetSwitch(this));
     }
     else if (ct.isTalkingPortrait())
     {
         return(new ActionTalkingPortrait(this));
     }
     else if (ct.isTransmission())
     {
         return(new ActionTransmission(this));
     }
     else if (ct.isUnmuteUnitSpeech())
     {
         return(new ActionUnmuteUnitSpeech(this));
     }
     else if (ct.isUnpauseGame())
     {
         return(new ActionUnpauseGame(this));
     }
     else if (ct.isUnpauseTimer())
     {
         return(new ActionUnpauseTimer(this));
     }
     else if (ct.isVictory())
     {
         return(new ActionVictory(this));
     }
     else if (ct.isWait())
     {
         return(new ActionWait(this));
     }
     throw new NotImplementedException();
 }
Exemple #2
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();
        }