public void PlayerTest() { var player = new HuntTheWumpus.Player(); int mem = player.Coins; player.AddCoins(100); player.AddCoins(0); Assert.True(mem + 100 == player.Coins, "AddCoins isn't correct"); mem += 100; player.BuyArrows(); Assert.True(mem > player.Coins, "BuyArrow isn't correct"); mem = player.Coins; player.BuyHint(); Assert.True(mem > player.Coins, "BuyHint isn't correct"); int ch = 0; while (player.CanBuyArrow() && ch < 1000) { player.BuyArrows(); ++ch; } Assert.True(ch < 1000, "CanBuyArrow isn't correct"); player.AddCoins(100); ch = 0; while (player.CanBuyHint() && ch < 1000) { player.BuyHint(); ++ch; } Assert.True(ch < 1000, "CanBuyHint isn't correct"); }
public void UpDate(long time) { if (state == ControlState.Cave) { List <string> listachiv = new List <string>(); map.GetAchievement(listachiv); if (minigame != null) { minigame.GetAchievement(listachiv); } player.GetAchievement(listachiv); score.getAchievement(listachiv); view.DrawCave(map.graph, map.isActive, map.GetDangerList(), map.danger, map.Room); if (!MiniGameEnd) { minigame.TickTime(); minigame.DrawMiniGame(view.Graphics); if (!minigame.Is_playing) { if (!minigame.Is_Winner && StoryMiniGame != StoryMG.BuyArrow && StoryMiniGame != StoryMG.BuyHint) { IsWin = false; EndGame(); } if (minigame.Is_Winner && StoryMiniGame == StoryMG.BuyHint) { int rnd = Utily.Next() % HintMessage.Count; Hint NowHint = (Hint)rnd; int HintData = 0; if (NowHint == Hint.Bat) { HintData = map.GetBat() + 1; } if (NowHint == Hint.Pit) { HintData = map.GetPit() + 1; } if (NowHint == Hint.Wumpus) { HintData = map.Wumpus + 1; } if (NowHint != Hint.NoLuck) { view.AddComand(HintMessage[(int)NowHint] + HintData, true); } else { view.AddComand(HintMessage[(int)NowHint], true); } } if (minigame.Is_Winner && StoryMiniGame == StoryMG.BuyArrow) { player.GiveArrows(); view.AddComand(Messages.GiveArrowsString, true, false); } if (minigame.Is_Winner && StoryMG.Wumpus == StoryMiniGame) { map.WumpusGoAway(); view.AddComand(Messages.WumpusRunString, true); } if (minigame.Is_Winner) { score.AddScores(50); } MiniGameEnd = true; } } else { view.DrawInterface(player.Coins, player.Arrow, map.Room, player.CanBuyArrow(), player.CanBuyHint()); } if (!CheckDanger && !view.MinimizeBat && !view.IsAnimated) { CheckDanger = true; if (map.danger == Danger.Pit) { minigame = new MiniGame(Width, Height); StoryMiniGame = StoryMG.Pit; minigame.HintText = Messages.PitHintText; minigame.InitializeMiniGame(PitDiff[Difficulty]); UseMiniGame = true; MiniGameEnd = false; } if (map.danger == Danger.Bat) { view.AddComand(Messages.MetBatString, true); map.Respaw(); } if (map.danger == Danger.Wumpus) { minigame = new MiniGame(Width, Height); StoryMiniGame = StoryMG.Wumpus; minigame.HintText = Messages.WumpusHintText; MiniGameEnd = false; UseMiniGame = true; minigame.InitializeMiniGame(WumpusDiff[Difficulty]); } Danger dangerabout = map.GetDangerAbout(); if (dangerabout == Danger.Bat) { view.AddComand(String.Format(Messages.BatWarning, map.Room + 1), true); } if (dangerabout == Danger.Pit) { view.AddComand(String.Format(Messages.PitWarning, map.Room + 1), true); } if (dangerabout == Danger.Wumpus) { string strout = String.Format(Messages.WumpusWarning, map.Room + 1); if (!player.IsShotArrow) { strout += Messages.HintRightClick; } view.AddComand(strout, true); } } if (map.IsWin && view.IsEndAnimation()) { IsWin = true; EndGame(); } else if (player.Arrow == 0 && view.IsEndAnimation()) { IsWin = false; EndGame(); } } if (state == ControlState.MainMenu) { view.DrawMainMenu(); } if (state == ControlState.PickCave) { view.DrawPickCave(MapForPiсk[numPickCave].graph, MapForPiсk[numPickCave].isActive, numPickCave, numDiff, seed); } if (time > 0) { view.DrawText((1000 / time).ToString(), 5, 5, 10, "Arial", Color.White); } if (score != null) { score.TickTime(); score.Draw(view.Graphics); } }