public void Input(string message) { switch (WhatAmIDoing.state) { case State.Types.Chatting: var parts = message.Split(' '); bool broken = false; switch (parts[0].ToLower()) { case "play": Games outGame = Games.None; if (parts.Length <= 1) { broken = true; break; } if (Enum.TryParse(parts[1], true, out outGame)) { WhatAmIDoing = new State(State.Types.Playing, outGame); WhatAmIPlaying = GetGame(outGame); Program.Loggit(this, string.Format("joue à {0}", WhatAmIPlaying.GameName), ConsoleColor.DarkYellow); } else { Tell("Le jeu \"" + parts[1] + "\" n'existe pas!"); } break; case "aide": Tell("Le seul jeu pour le moment c'est HotAndCold :P Pour jouer entre\nPlay HotAndCold"); break; default: Tell(new string(message.Reverse().ToArray())); break; } if (broken) { Tell(new string(message.Reverse().ToArray())); } break; case State.Types.Playing: switch (WhatAmIDoing.currentlyPlaying) { case Games.None: QuitGame(); break; default: WhatAmIPlaying.Input(message); break; } break; default: break; } }
internal void QuitGame() { Tell("De retour au chat!"); Program.Loggit(this, "a quitté le jeu", ConsoleColor.DarkYellow); WhatAmIDoing = new State(State.Types.Chatting); WhatAmIPlaying = null; }