/// <summary> /// Starts the order for the specified game and hero. /// </summary> /// <param name="game">The game.</param> /// <param name="who">The who.</param> /// <returns></returns> public string Start(Game game, IOrderTaker who) { return string.Empty; }
public Factory(IOrderTaker orderTaker, IReportGenerator reportGenerator) { _orderTaker = orderTaker; _reportGenerator = reportGenerator; }
/// <summary> /// Ends the order for the specified game and hero. /// </summary> /// <param name="game">The game.</param> /// <param name="who">The who.</param> /// <returns></returns> string IOrder.End(Game game, IOrderTaker who) { return string.Empty; }
/// <summary> /// Determines whether this order can start. /// </summary> /// <param name="game">The game.</param> /// <param name="who">The who.</param> /// <param name="logline">The logline.</param> /// <returns></returns> public bool CanStart(Game game, IOrderTaker who, out string logline) { logline = string.Empty; return true; }
/// <summary> /// Starts the order for the specified game and hero. /// </summary> /// <param name="game">The game.</param> /// <param name="who">The who.</param> /// <returns></returns> public string Start(Game game, IOrderTaker who) { // Our start condition checked and who is a Hero Hero h = who as Hero; if (h == null) throw new InvalidOperationException("This cannot happen since the cast was checked at start condition"); return h.Name + " starts negotiations to hire a new hero." + Environment.NewLine; }
/// <summary> /// Ends the order for the specified game and hero. /// </summary> /// <param name="game">The game.</param> /// <param name="who">The who.</param> /// <returns></returns> public string End(Game game, IOrderTaker who) { // Our start condition checked and who is a Hero Hero h = who as Hero; if (h == null) throw new InvalidOperationException("This cannot happen since the cast was checked at start condition"); string newheroname = (string)this.Parameters["name"]; Hero newhero = new Hero(); newhero.Identifier = game.Pool.ConsumeIdentifier(); newhero.Name = newheroname; h.Owner.Heroes.Add(newhero.Identifier, newhero); return h.Name + " hires " + newheroname + "." + Environment.NewLine; }
/// <summary> /// Determines whether this order can start. /// </summary> /// <param name="game">The game.</param> /// <param name="who">The who.</param> /// <param name="logline">The logline.</param> /// <returns></returns> public bool CanStart(Game game, IOrderTaker who, out string logline) { // check if the hero is in a city // check if the player has hero points left // should we also check on the length of the name being given? if (who is Hero) { logline = string.Empty; return true; } logline = "Only heroes can hire other heroes." + Environment.NewLine; return false; }
/// <summary> /// Ends the order for the specified game and hero. /// </summary> /// <param name="game">The game.</param> /// <param name="who">The who.</param> /// <returns></returns> public string End(Game game, IOrderTaker who) { if (!Parameters.ContainsKey("name")) throw new InvalidOperationException("This cannot happen, parsed Name order should have parameter name"); string newname = (string)Parameters["name"]; if (who is Player) { Player p = who as Player; string oldname = p.Name; p.Name = newname; return "Player renamed from " + oldname + "to " + newname + "." + Environment.NewLine; } if (who is Hero) { Hero h = who as Hero; string oldname = h.Name; h.Name = newname; return "Hero renamed from " + oldname + "to " + newname + "." + Environment.NewLine; } return "An error occurred while trying to use the order Name." + Environment.NewLine; }
/// <summary> /// Determines whether this order can start. /// </summary> /// <param name="game">The game.</param> /// <param name="who">The who.</param> /// <param name="logline">The logline.</param> /// <returns></returns> public bool CanStart(Game game, IOrderTaker who, out string logline) { // no requirements on naming players or heroes logline = string.Empty; return true; }