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 MouseDown(object sender, MouseEventArgs e) { if (state == ControlState.Cave && !MiniGameEnd) { minigame.Down(e); } if (state == ControlState.Cave && MiniGameEnd && view.IsEndAnimation()) { view.StopAnimation(); RegionCave rg = view.GetRegionCave(e.X, e.Y); if (rg >= 0 && (int)rg < 6 && map.isActive[map.Room][(int)rg]) { if (e.Button == MouseButtons.Left) { int WumpusRun = Utily.Next() % 8; if (WumpusRun < Difficulty) { map.WumpusGoAway(1); } int add = map.Move((int)rg); player.AddCoins(add); score.AddScores(5 * add); view.StartAddCoinAnimation(add); if (map.danger == Danger.Bat) { view.StartBatAnimation(); } view.StartMoveAnimation((int)rg); CheckDanger = false; } else { player.PushArrow(); map.PushArrow((int)rg); view.StartArrowAnimation((int)rg); List <string> achiv = new List <string>(); player.GetAchievement(achiv); score.getAchievement(achiv); } } if (rg == RegionCave.BuyArrow) { if (player.CanBuyArrow()) { StoryMiniGame = StoryMG.BuyArrow; MiniGameEnd = false; minigame = new MiniGame(Width, Height); minigame.HintText = Messages.ArrowHintText; minigame.InitializeMiniGame(ArroDiff[Difficulty]); UseMiniGame = true; player.BuyArrows(); } else { view.AddComand(string.Format(Messages.NotEnoughCoins, player.NeedForBuyArrows()), true, false); } } if (rg == RegionCave.BuyHint) { if (player.CanBuyHint()) { StoryMiniGame = StoryMG.BuyHint; MiniGameEnd = false; minigame = new MiniGame(Width, Height); minigame.HintText = Messages.HintHintText; minigame.InitializeMiniGame(HintDiff[Difficulty]); UseMiniGame = true; player.BuyHint(); } else { view.AddComand(string.Format(Messages.NotEnoughCoins, player.NeedForBuyHint()), true, false); } } if (rg == RegionCave.UpConsole) { view.ChangeIndex(1); } if (rg == RegionCave.DownConsole) { view.ChangeIndex(-1); } } if (state == ControlState.MainMenu) { RegionMenu rg = view.GetRegionMainMenu(e.X, e.Y); if (rg == RegionMenu.NewGame) { NewGame(); } if (rg == RegionMenu.Continue) { ContinueMenu(); } if (rg == RegionMenu.ScoreList) { score = new Scores(Width, Height); score.LoadLeaders(false); state = ControlState.ScoreList; } if (rg == RegionMenu.Exit) { Application.Exit(); } } if (state == ControlState.PickCave) { RegionPickCave rg = view.GetRegionPickCave(e.X, e.Y); int Intrg = (int)rg; if (Intrg < 5) { numPickCave = Intrg; } if (Intrg >= (int)RegionPickCave.Diff1 && Intrg <= (int)RegionPickCave.Diff3) { numDiff = Intrg - (int)RegionPickCave.Diff1; } if (rg == RegionPickCave.Play) { StartAfterPick(); } } }