Beispiel #1
0
 public void reset()
 {
     message            = null;
     attempt            = 0;
     skillResult        = null;
     wantedThrustTarget = null;
 }
Beispiel #2
0
        public void handlePlayerOutput(int frame, int round, int playerIdx, String[] outputs)
        {
            Player player   = players[playerIdx];
            String expected = EXPECTED;

            for (int i = 0; i < LOOTER_COUNT; ++i)
            {
                String line = outputs[i];
                Match  match;
                try {
                    Looter looter = players[playerIdx].looters[i];

                    match = PLAYER_WAIT_PATTERN.Match(line);
                    if (match.Success)
                    {
                        looter.attempt = Action.WAIT;
                        matchMessage(looter, match);
                        continue;
                    }

                    match = PLAYER_MOVE_PATTERN.Match(line);
                    if (match.Success)
                    {
                        looter.attempt = Action.MOVE;
                        int x     = Int32.Parse(match.Groups["x"].Value);
                        int y     = Int32.Parse(match.Groups["y"].Value);
                        int power = Int32.Parse(match.Groups["power"].Value);

                        looter.setWantedThrust(new Point(x, y), power);
                        matchMessage(looter, match);
                        continue;
                    }

                    match = PLAYER_SKILL_PATTERN.Match(line);
                    if (match.Success)
                    {
                        if (!looter.skillActive)
                        {
                            // Don't kill the player for that. Just do a WAIT instead
                            looter.attempt = Action.WAIT;
                            matchMessage(looter, match);
                            continue;
                        }

                        looter.attempt = Action.SKILL;
                        int x = Int32.Parse(match.Groups["x"].Value);
                        int y = Int32.Parse(match.Groups["y"].Value);

                        SkillResult result = new SkillResult(x, y);
                        looter.skillResult = result;

                        try {
                            SkillEffect effect = looter.skill(new Point(x, y));
                            skillEffects.Add(effect);
                        } catch (NoRageException /*e*/) {
                            result.code = SkillResult.NO_RAGE;
                        } catch (TooFarException /*e*/) {
                            result.code = SkillResult.TOO_FAR;
                        }
                        matchMessage(looter, match);
                        continue;
                    }

                    throw new InvalidInputException(expected, line);
                } catch (InvalidInputException e) {
                    player.Kill();
                    throw e;
                } catch (Exception e) {
                    //StringWriter errors = new StringWriter();
                    //e.printStackTrace(new PrintWriter(errors));
                    //printError(e.getMessage() + "\n" + errors.toString());
                    System.Diagnostics.Debug.WriteLine(e);
                    player.Kill();
                    throw new InvalidInputException(expected, line);
                }
            }
        }