Example #1
0
        void OnReinforceUnit(ClientToServerMessage message)
        {
            ReinforceUnitRequest request = message.ReinforceUnitRequest;

            if (request == null)
            {
                throw new ServerClientException("Invalid unit reinforcement request");
            }
            Unit unit = PlayerState.GetUnit(request.UnitId);

            if (unit == null)
            {
                throw new ServerClientException("Encountered an invalid unit ID in a reinforcement request");
            }
            PlayerState.ReinforceUnit(unit);
            UnitReinforcementBroadcast unitReinforced = new UnitReinforcementBroadcast(new ReinforcementState(PlayerState), unit.Id, unit.Strength);
            ServerToClientMessage      broadcast      = new ServerToClientMessage(unitReinforced);

            BroadcastMessage(broadcast);
        }
Example #2
0
 public ClientToServerMessage(ReinforceUnitRequest request)
 {
     Type = ClientToServerMessageType.ReinforceUnit;
     ReinforceUnitRequest = request;
 }