예제 #1
0
파일: APlayer.cs 프로젝트: gleroi/k-rabbit
 public static void Is(Player player, int x, int y, int score, PlayerState state)
 {
     Assert.Equal(x, player.Pos.X);
     Assert.Equal(y, player.Pos.Y);
     Assert.Equal(score, player.Score);
     Assert.Equal(state, player.State);
 }
예제 #2
0
        public WorldState ApplyAction(int iplayer, Direction direction)
        {
            Point npos = this.GetNewPos(iplayer, direction);
            var nplayers = new List<Player>(this.World.Players);
            var ncompteurs = new List<Compteur>(this.World.Compteurs);
            WorldState newWorld = WorldState.Create(this.World.Round, nplayers, ncompteurs, this.World.Caddies);

            var player = this.World.Players[iplayer];
            if (this.IsValidMove(iplayer, npos))
            {
                var nplayer = new Player(player.Id, npos.X, npos.Y, player.Score, PlayerState.Playing);
                newWorld.Players[iplayer] = nplayer;

                this.HandleCompteurRules(newWorld, iplayer);
                this.HandleBaffe(newWorld, iplayer);
            }
            else
            {
                newWorld.Players[iplayer] = new Player(iplayer, player.Pos.X, player.Pos.Y, player.Score - 5,
                                                       PlayerState.Stunned);
            }
            this.World = newWorld;

            return this.World;
        }
예제 #3
0
 internal void CheckCompteur(ref Player player)
 {
     if (!player.HasCompteur)
     {
         var pos = player.Pos;
         var compteurId = this.Compteurs.FindIndex(cp => cp.Pos == pos);
         player.UpdateCompteur(compteurId);
         if (compteurId != -1)
         {
             var compteur = this.Compteurs[compteurId];
             compteur.UpdatePlayer(player.Id);
             this.Compteurs[compteurId] = compteur;
         }
     }
 }