Пример #1
0
 private static XElement XmlPiece(Piece p)
 {
     XElement piece = new XElement("Piece");
     piece.Add(new XAttribute("ID", p.ID));
     piece.Add(XmlPoint(p.Position));
     piece.Add(new XElement("Alive", p.Alive));
     piece.Add(new XElement("Active", p.Active));
     piece.Add(new XElement("TurnsOnCurrentPosition", p.TurnsOnCurrentPosition));
     piece.Add(new XElement("TrainMovementStreak", p.TrainMovementStreak));
     return piece;
 }
Пример #2
0
 public bool allowedToMovePiece(Piece p)
 {
     return Piece.Active && p == Piece;
 }
Пример #3
0
 public bool allowedToMovePiece(Piece p)
 {
     return p.Type == PieceType.Police && p.Active;
 }
Пример #4
0
 /// <summary>
 /// Moves a piece to the target destination if allowed
 /// </summary>
 /// <param name="p">Piece to be moved</param>
 /// <param name="pt">Destination</param>
 /// <returns>True if move was successful</returns>
 private bool movePiece(Piece p, Point pt)
 {
     if (ruleEngine.canArrestAt(p, pt))
     {
         Thief arrestTarget = (Thief)State.Board.getPieceAt(pt);
         makeArrest(p, arrestTarget);
     }
     else
     {
         if (logicEngine.movedByTrain(p.Position, pt)) p.TrainMovementStreak++;
         else p.TrainMovementStreak = 0;
         p.Position = pt;
         p.TurnsOnCurrentPosition = 0;
         if (p.Type == PieceType.Thief) attemptToRobPos((Thief)p, pt);
     }
     p.TurnsOnCurrentPosition++;
     endTurn();
     return true;
 }
Пример #5
0
 private void makeArrest(Piece police, Thief thief)
 {
     State.PolicePlayer.Money += ruleEngine.arrest(thief, police);
     if (thief.ArrestCount == RuleEngine.MAX_ARRESTS)
     {
         ruleEngine.removePieceFromGame(police);
         ruleEngine.removePieceFromGame(thief);
     }
 }