/// <summary> /// Execute DEPLOY command, adding unit to the state and calling view.DeployUnit. /// Note that Execute and Undo are called just by clicking lines in the log. Each "command" log line is tied to a command. The command persists with the log line. When the /// </summary> /// <param name="state"></param> /// <returns></returns> override public Matchstate Execute(Matchstate state) { Debug.Log($"CommandDeploy({ToString()})"); unit = new Bopper.Unit(unitType, player_id, coord, layer, name); if (unit == null) { throw new Exception($"UNIT IS NULL"); } Debug.Assert(unit.data != null, "UNIT DATA IS NULL"); if (unit.data == null) { throw new Exception($"unit.name={unit.name}, unit.data={unit.data.name}: UNIT DATA IS NULL"); } Debug.Assert(unit.data.counterPrefab != null, $"unit.data.name={unit.data.name} does not have a counterPrefab"); if (unit.data == null || unit.data.counterPrefab == null) { throw new Exception($"unit.data.name={unit.data.name} str={unit.data.strength} does not have a counterPrefab"); } Debug.Log($"{unit} utype={unit.data.unitType}"); //index = state.units.Count; state.units.Add(unit); //state.SetStatus(CommandStatus.Type.Deploy, unit.id); //state.SetStatus($"DEPLOY {unit.name} in hex {unit.coord}"); //view.Display(this); // we can have only one view. Right now it must be Bopper.View.Unity.GameView. Views need to know about Commands ViewMaster.deployListeners?.Invoke(unit, ToString()); // we don't need to know about anything about any view(s). Views don't need to know anything about Commands return(state); }
override public Matchstate Execute(Matchstate state) { unit = new Bopper.Unit(unitType, player_id, coord, layer); state.units.Add(unit); ViewMaster.deployListeners?.Invoke(unit, ToString()); // we don't need to know about anything about any view(s). Views don't need to know anything about Commands return(state); }
/// <summary> /// Execute DEPLOY command, adding unit to the state and calling view.DeployUnit. /// Note that Execute and Undo are called just by clicking lines in the log. Each "command" log line is tied to a command. The command persists with the log line. When the /// </summary> /// <param name="state"></param> /// <returns></returns> override public Matchstate Execute(Matchstate state) { Debug.Log(ToString()); ViewMaster.phaseListeners?.Invoke(name); // we don't need to know about anything about any view(s). Views don't need to know anything about Commands return(state); }
override public Matchstate Execute(Matchstate state) { previousName = state.players[player_id].name; state.players[player_id].name = name; return(state); }
override public Matchstate Undo(Matchstate state) { ViewMaster.undeployListeners?.Invoke(unit); // we don't need to know about anything about any view(s). Views don't need to know anything about Commands //view.DisplayUndeploy(unit); //state.units.RemoveAt(index); state.units.Remove(unit); return(state); }
override public Matchstate Undo(Matchstate state) { //view.UndeployUnit(unit); //state.units.RemoveAt(index); unit.coord = prevCoord; unit.layer = prevLayer; ViewMaster.unmoveListeners?.Invoke(unit, coord, layer); return(state); }
/// <summary> /// Execute DEPLOY command, adding unit to the state and calling view.DeployUnit. /// Note that Execute and Undo are called just by clicking lines in the log. Each "command" log line is tied to a command. The command persists with the log line. When the /// </summary> /// <param name="state"></param> /// <returns></returns> override public Matchstate Execute(Matchstate state) { Debug.Log(ToString()); unit = state.findUnit(player_id, unit_name); Debug.Log($"Move: unit={unit}"); prevCoord = unit.coord; prevLayer = unit.layer; prevCoord = unit.coord; unit.coord = coord; unit.layer = layer; ViewMaster.moveListeners?.Invoke(unit, prevCoord, prevLayer, ToString()); // we don't need to know about anything about any view(s). Views don't need to know anything about Commands return(state); }
override public Matchstate Undo(Matchstate state) { return(state); }
override public Matchstate Execute(Matchstate state) { return(state); }
override public Matchstate Undo(Matchstate state) { state.players[player_id].shortname = previousShortname; return(state); }
override public Matchstate Execute(Matchstate state) { previousShortname = state.players[player_id].shortname; state.players[player_id].shortname = shortname;; return(state); }
override public Matchstate Undo(Matchstate state) { state.players[player_id].pta[(int)unitType] = previousType; return(state); }
override public Matchstate Execute(Matchstate state) { previousType = state.players[player_id].pta[(int)unitType]; state.players[player_id].pta[(int)unitType] = targetType; return(state); }
override public Matchstate Execute(Matchstate state) { state.messages.Add($"{state.players[player_id].name}: {message}"); return(state); }
override public Matchstate Undo(Matchstate state) { Debug.Log("Revert " + ToString()); return(state); }
public long id; // for OSA abstract public Matchstate Execute(Matchstate state);
abstract public Matchstate Undo(Matchstate state);
override public Matchstate Undo(Matchstate state) { state.messages.RemoveAt(state.messages.Count - 1); return(state); }