public void ChoosingAnInvalidTargetDoesntNothing() { Game gameFixture = new Game(); Card FiveOfCannons = new Card() { Suit = Suites.Cannons, Value = 5 }; Card FiveOfKeys = new Card { Suit = Suites.Keys, Value = 5 }; GameHelpers.BringCardFromDeckToField(ref gameFixture, FiveOfCannons); GameHelpers.BringCardFromDeckToScoreZone(ref gameFixture, FiveOfKeys, 1); GameHelpers.SetCurrentActions(ref gameFixture, new List <Actions> { Actions.ChooseCannonTarget }); typeof(Game).GetField("DoesCannonNeedTarget", BindingFlags.NonPublic | BindingFlags.Instance) .SetValue(gameFixture, true); gameFixture.TakeAction(Actions.ChooseCannonTarget, new Card() { Suit = Suites.Chests, Value = 5 }); gameFixture.CurrentAvailableActions.Should().BeEquivalentTo( new List <Actions>() { Actions.ChooseCannonTarget }); gameFixture.DiscardPile.Count.Should().Be(10); }
public void BustingWithAnAnchorOutProtectsEarlierCards() { Game gameFixture = new Game(); Card FiveOfKeys = new Card() { Suit = Suites.Keys, Value = 5 }; Card FiveOfAnchors = new Card() { Suit = Suites.Anchors, Value = 5 }; Card SevenOfKeys = new Card() { Suit = Suites.Keys, Value = 7 }; GameHelpers.ClearDiscardPile(ref gameFixture); GameHelpers.BringCardFromDeckToField(ref gameFixture, FiveOfKeys); GameHelpers.BringCardFromDeckToField(ref gameFixture, FiveOfAnchors); GameHelpers.BringCardToPositionInDeck(ref gameFixture, SevenOfKeys, 0); GameHelpers.SetCurrentActions(ref gameFixture, new List <Actions> { Actions.Draw }); gameFixture.TakeAction(Actions.Draw); gameFixture.ScoreZones[0].PointsShowing().Should().Be(5); gameFixture.ScoreZones[0].HighestOfSuit(Suites.Anchors).Should().BeNull(); gameFixture.ScoreZones[0].HighestOfSuit(Suites.Keys).Should().NotBeNull(); gameFixture.ScoreZones[0].HighestOfSuit(Suites.Keys).Value.Should().Be(5); gameFixture.DiscardPile.Count.Should().Be(2); }
public void ChoosingATargetPutsThatCardIntoTheDiscard() { Game gameFixture = new Game(); Card FiveOfCannons = new Card() { Suit = Suites.Cannons, Value = 5 }; Card FiveOfKeys = new Card { Suit = Suites.Keys, Value = 5 }; GameHelpers.BringCardFromDeckToField(ref gameFixture, FiveOfCannons); GameHelpers.BringCardFromDeckToScoreZone(ref gameFixture, FiveOfKeys, 1); GameHelpers.SetCurrentActions(ref gameFixture, new List <Actions> { Actions.ChooseCannonTarget }); typeof(Game).GetField("DoesCannonNeedTarget", BindingFlags.NonPublic | BindingFlags.Instance) .SetValue(gameFixture, true); gameFixture.TakeAction(Actions.ChooseCannonTarget, FiveOfKeys); gameFixture.DiscardPile.Count.Should().Be(11); gameFixture.ScoreZones[1].PointsShowing().Should().Be(0); gameFixture.CurrentAvailableActions.Should().BeEquivalentTo( new List <Actions>() { Actions.Draw, Actions.TakeAll }, options => options.WithoutStrictOrdering()); }
public async Task <GameActionViewModel[]> Handle(HostChosePlayerCommand request) { var game = _context.Games .Include(x => x.Players.Select(p => p.User)) .FirstOrDefault(x => x.GameId == request.GameId); if (game.HostId != request.UserId) { throw new ValidationException(new[] { new ValidationFailure("HostId", $"User with Id of \"{request.UserId}\" is not the host.") }); } // chose player game var nextPlayer = game.Players.Single(x => x.UserId == request.NextPlayerId); var gameActionList = new List <GameAction>(); game.CurrentGamePlayerId = nextPlayer.GamePlayerId; var gameAction = new GameAction { GameId = request.GameId, UserId = request.UserId, DateTime = DateTime.Now, Action = (int)Actions.StatusChanged, ActionValue = $"has selected the next player \"{nextPlayer.User.DisplayName}\"." }; _context.GameActions.Add(gameAction); game.Status = (int)GameStatus.WaitingForPlayer; gameActionList.Add(gameAction); await _context.SaveChangesAsync(); return(GameHelpers.ProcessNextPlayerResults(gameActionList, nextPlayer, gameAction, _context)); }
public Map(BinaryReader reader, byte mapGroup) { RomOffset = reader.BaseStream.Position; ParentGroup = mapGroup; RomBank = reader.ReadByte(); Tileset = reader.ReadByte(); Type = reader.ReadByte(); HeaderPointer = reader.ReadUInt16(); TownMapLocation = reader.ReadByte(); Unknown1 = reader.ReadByte(); Unknown2 = reader.ReadByte(); if (!IsValid) { return; } long positionBackup = reader.BaseStream.Position; reader.BaseStream.Position = GameHelpers.CalculateOffset(RomBank, HeaderPointer); PrimaryHeader = new PrimaryMapHeader(reader); reader.BaseStream.Position = GameHelpers.CalculateOffset((byte)(reader.BaseStream.Position >> 14), PrimaryHeader.SecondaryHeaderPointer); SecondaryHeader = new SecondaryMapHeader(reader); reader.BaseStream.Position = GameHelpers.CalculateOffset((byte)(reader.BaseStream.Position >> 14), PrimaryHeader.MapDataPointer); MapData = reader.ReadBytes(PrimaryHeader.Width * PrimaryHeader.Height); reader.BaseStream.Position = positionBackup; }
public void ChoosingATargetBringsThatCardIntoTheField() { Game gameFixture = new Game(); Card FiveOfHooks = new Card() { Suit = Suites.Hooks, Value = 5 }; Card FiveOfKeys = new Card { Suit = Suites.Keys, Value = 5 }; GameHelpers.BringCardFromDeckToField(ref gameFixture, FiveOfHooks); GameHelpers.BringCardFromDeckToScoreZone(ref gameFixture, FiveOfKeys, 0); GameHelpers.SetCurrentActions(ref gameFixture, new List <Actions> { Actions.ChooseHookTarget }); gameFixture.TakeAction(Actions.ChooseHookTarget, FiveOfKeys); gameFixture.Field.Count.Should().Be(2); gameFixture.Field[1].Should().BeEquivalentTo(FiveOfKeys); gameFixture.ScoreZones[0].PointsShowing().Should().Be(0); gameFixture.CurrentAvailableActions.Should().BeEquivalentTo( new List <Actions>() { Actions.Draw, Actions.TakeAll }, options => options.WithoutStrictOrdering()); }
// Update is called once per frame public void Update() { timeLeft -= Time.deltaTime; if (timeLeft <= 0f) { GameHelpers.GetPlayerController().Die(); } if (timeLeft < 5.51f) { textComponent.color = StandardColor.Red.GetColor(); } else { textComponent.color = StandardColor.White.GetColor(); } if (timeLeft < 3.51f) { animatorComponent.enabled = true; } textComponent.text = string.Format("{0,3:0}", timeLeft); }
public void Start() { canvasObject = gameObject.transform.Find(StaticNames.PauseCanvas).gameObject; playerController = GameHelpers.GetPlayerController(); canvasObject.SetActive(false); }
public void DrawingAKrakenBustsWithoutAdditionalDraws() { Game gameFixture = new Game(); GameHelpers.BringCardToPositionInDeck(ref gameFixture, new Card { Suit = Suites.Krakens, Value = 7 }, 0); GameHelpers.BringCardToPositionInDeck(ref gameFixture, new Card { Suit = Suites.Keys, Value = 5 }, 1); GameHelpers.BringCardFromDeckToField(ref gameFixture, new Card { Suit = Suites.Krakens, Value = 5 }); GameHelpers.ClearDiscardPile(ref gameFixture); gameFixture.TakeAction(Actions.Draw); gameFixture.Field.Count.Should().Be(0); gameFixture.DiscardPile.Count.Should().Be(2); List <Card> deckCards = typeof(Deck).GetField("Cards", BindingFlags.NonPublic | BindingFlags.Instance) .GetValue(gameFixture.Deck) as List <Card>; deckCards[0].Should().BeEquivalentTo(new Card { Suit = Suites.Keys, Value = 5 }); gameFixture.CurrentPlayersTurn.Should().Be(Players.PlayerTwo); }
public void AskingForMapCardsReturnsThree() { Game gameFixture = new Game(); Card FiveOfMaps = new Card { Suit = Suites.Maps, Value = 5 }; Card FiveOfKeys = new Card { Suit = Suites.Keys, Value = 5 }; Card FiveOfCannons = new Card { Suit = Suites.Cannons, Value = 5 }; Card FiveOfChests = new Card { Suit = Suites.Chests, Value = 5 }; GameHelpers.BringCardFromDeckToField(ref gameFixture, FiveOfMaps); GameHelpers.ClearDiscardPile(ref gameFixture); GameHelpers.BringCardFromDeckToDiscardPile(ref gameFixture, FiveOfKeys); GameHelpers.BringCardFromDeckToDiscardPile(ref gameFixture, FiveOfChests); GameHelpers.BringCardFromDeckToDiscardPile(ref gameFixture, FiveOfCannons); GameHelpers.SetCurrentActions(ref gameFixture, new List <Actions> { Actions.ChooseMapTarget }); var actual = gameFixture.GetMapCards(); actual.Should().BeEquivalentTo(new List <Card> { FiveOfKeys, FiveOfChests, FiveOfCannons }, options => options.WithoutStrictOrdering()); }
public void TakingBothAChestAndAKeyWhenTheDiscardIsLowYeildsAsMuchAsPossible() { Game gameFixture = new Game(); Card FiveOfKeys = new Card { Suit = Suites.Keys, Value = 5 }; Card FiveOfChests = new Card { Suit = Suites.Chests, Value = 5 }; GameHelpers.BringCardFromDeckToField(ref gameFixture, FiveOfKeys); GameHelpers.BringCardFromDeckToField(ref gameFixture, FiveOfChests); GameHelpers.ClearDiscardPile(ref gameFixture); GameHelpers.BringCardFromDeckToDiscardPile(ref gameFixture, new Card { Suit = Suites.Oracles, Value = 5 }); GameHelpers.SetCurrentActions(ref gameFixture, new List <Actions> { Actions.TakeAll }); gameFixture.TakeAction(Actions.TakeAll); gameFixture.ScoreZones[0].PointsShowing().Should().Be(15); gameFixture.DiscardPile.Count.Should().Be(0); }
public void DrawingAMapFirstButTheDiscardIsEmptyDoesntEndTheKraken() { Game gameFixture = new Game(); GameHelpers.BringCardToPositionInDeck(ref gameFixture, new Card { Suit = Suites.Krakens, Value = 5 }, 0); GameHelpers.BringCardToPositionInDeck(ref gameFixture, new Card { Suit = Suites.Maps, Value = 5 }, 1); GameHelpers.BringCardToPositionInDeck(ref gameFixture, new Card { Suit = Suites.Oracles, Value = 5 }, 2); GameHelpers.ClearDiscardPile(ref gameFixture); gameFixture.TakeAction(Actions.Draw); gameFixture.CurrentAvailableActions.Should().BeEquivalentTo( new List <Actions> { Actions.Draw, Actions.TakeAll }, options => options.WithoutStrictOrdering()); gameFixture.Field.Count.Should().Be(3); gameFixture.Field[2].Should().Match(a => (a as Card).Suit == Suites.Oracles && (a as Card).Value == 5); }
public static void greenTxtScreen() { GameHelpers.SpaceandClean(); GameHelpers.TextSpace(); Console.BackgroundColor = ConsoleColor.DarkGreen; Console.ForegroundColor = ConsoleColor.White; }
public async Task <GameActionViewModel[]> Handle(StartGameCommand request) { var game = _context.Games .Include(x => x.Players.Select(p => p.User)) .FirstOrDefault(x => x.GameId == request.GameId); if (game.HostId != request.UserId) { throw new ValidationException(new[] { new ValidationFailure("HostId", $"User with Id of \"{request.UserId}\" is not the host.") }); } // Start game var gameActionList = new List <GameAction>(); var gameAction = new GameAction { GameId = request.GameId, UserId = request.UserId, DateTime = DateTime.Now, Action = (int)Actions.StartedGame, ActionValue = "has started the game." }; _context.GameActions.Add(gameAction); gameActionList.Add(gameAction); // set next player GamePlayer nextPlayer; GameAction nextPlayerAction; GameHelpers.GetNexPlayer(request, game, gameActionList, out nextPlayer, out nextPlayerAction, _context); await _context.SaveChangesAsync(); return(GameHelpers.ProcessNextPlayerResults(gameActionList, nextPlayer, nextPlayerAction, _context)); }
public void OnCollisionEnter2D(Collision2D collision) { if (collision.collider.tag == StaticNames.Player) { switch (PowerUp) { case PowerUpType.SlowDownEnemies: GameHelpers.GetPowerUpController(StaticNames.PowerUpSlowDown).Increase(1); break; case PowerUpType.HiddenFromEnemies: GameHelpers.GetPowerUpController(StaticNames.PowerUpHidden).Increase(1); break; case PowerUpType.IncreaceTime: var rnd = new System.Random(); var time = rnd.Next(3, 10); GameHelpers.GetHUDLevelTimeLeft().IncreaseTime(time); break; default: break; } Destroy(gameObject, 0); } }
private bool CraftRandomStuffOverValue(int value) { var tmpList = Game.User.zt.Values.ToList(); tmpList.Shuffle(); foreach (var blueprint in tmpList) { ItemData itemData = Game.Data.ep(blueprint.b0); string fullName = Game.Texts.GetText(blueprint.ai8()); if (!Settings.RegularCrafting.IncludeElements || !Settings.RegularCrafting.IncludeRune) { if (itemData.Type == ItemData.ItemType.Tag || itemData.Type == ItemData.ItemType.Rune) { continue; } } if (itemData.Value < value) { continue; } if (GameHelpers.StartCraft(blueprint.b0)) { Log.Instance.Info($"started crafting: {blueprint.b0}", ConsoleColor.Green); return(true); } Log.Instance.Error($"not enough materials too craft: {fullName}"); return(false); } return(false); }
private bool CraftBookMarked() { foreach (var blueprint in Game.User.zt.Values.ToList()) { if (Settings.RegularCrafting.CraftBookmarked) { string fullName = Game.Texts.GetText(blueprint.ai8()); if (!blueprint.ck) { continue; } if (GameHelpers.StartCraft(blueprint.b0)) { Log.Instance.Info($"started crafting: {blueprint.b0}", ConsoleColor.Green); return(true); } Log.Instance.Info($"not enough materials too craft: {fullName}", ConsoleColor.Red); } } return(false); }
public void DrawingIntoAHookButBustingBusts() { Game gameFixture = new Game(); Card FiveOfHooks = new Card() { Suit = Suites.Hooks, Value = 5 }; Card SevenOfHooks = new Card() { Suit = Suites.Hooks, Value = 7 }; GameHelpers.BringCardFromDeckToField(ref gameFixture, FiveOfHooks); GameHelpers.BringCardToPositionInDeck(ref gameFixture, SevenOfHooks, 0); gameFixture.TakeAction(Actions.Draw); gameFixture.CurrentAvailableActions.Should().BeEquivalentTo( new List <Actions>() { Actions.Draw }, options => options.WithoutStrictOrdering()); gameFixture.Field.Count.Should().Be(0); gameFixture.CurrentPlayersTurn.Should().Be(Players.PlayerTwo); gameFixture.ScoreZones[0].PointsShowing().Should().Be(0); gameFixture.DiscardPile.Count.Should().Be(12); }
public void MappingIntoABustBusts() { Game gameFixture = new Game(); Card FiveOfMaps = new Card { Suit = Suites.Maps, Value = 5 }; Card SevenOfMaps = new Card() { Suit = Suites.Maps, Value = 7 }; GameHelpers.BringCardFromDeckToField(ref gameFixture, FiveOfMaps); GameHelpers.ClearDiscardPile(ref gameFixture); GameHelpers.BringCardFromDeckToDiscardPile(ref gameFixture, SevenOfMaps); GameHelpers.SetCurrentActions(ref gameFixture, new List <Actions> { Actions.ChooseMapTarget }); gameFixture.GetMapCards(); gameFixture.TakeAction(Actions.ChooseMapTarget, SevenOfMaps); gameFixture.CurrentAvailableActions.Should().BeEquivalentTo( new List <Actions>() { Actions.Draw }, options => options.WithoutStrictOrdering()); gameFixture.Field.Count.Should().Be(0); gameFixture.CurrentPlayersTurn.Should().Be(Players.PlayerTwo); gameFixture.ScoreZones[0].PointsShowing().Should().Be(0); gameFixture.DiscardPile.Count.Should().Be(2); }
public void ChoosingATargetThatWouldBustBusts() { Game gameFixture = new Game(); Card FiveOfHooks = new Card() { Suit = Suites.Hooks, Value = 5 }; Card SevenOfHooks = new Card() { Suit = Suites.Hooks, Value = 7 }; GameHelpers.BringCardFromDeckToField(ref gameFixture, FiveOfHooks); GameHelpers.BringCardFromDeckToScoreZone(ref gameFixture, SevenOfHooks, 0); GameHelpers.SetCurrentActions(ref gameFixture, new List <Actions> { Actions.ChooseHookTarget }); gameFixture.TakeAction(Actions.ChooseHookTarget, SevenOfHooks); gameFixture.CurrentAvailableActions.Should().BeEquivalentTo( new List <Actions>() { Actions.Draw }, options => options.WithoutStrictOrdering()); gameFixture.Field.Count.Should().Be(0); gameFixture.CurrentPlayersTurn.Should().Be(Players.PlayerTwo); gameFixture.ScoreZones[0].PointsShowing().Should().Be(0); gameFixture.ScoreZones[1].PointsShowing().Should().Be(0); gameFixture.DiscardPile.Count.Should().Be(12); }
public void ChoosingAnInvalidTargetDoesntNothing() { Game gameFixture = new Game(); Card FiveOfHooks = new Card() { Suit = Suites.Hooks, Value = 5 }; Card FiveOfKeys = new Card { Suit = Suites.Keys, Value = 5 }; GameHelpers.BringCardFromDeckToField(ref gameFixture, FiveOfHooks); GameHelpers.BringCardFromDeckToScoreZone(ref gameFixture, FiveOfKeys, 0); GameHelpers.SetCurrentActions(ref gameFixture, new List <Actions> { Actions.ChooseHookTarget }); gameFixture.TakeAction(Actions.ChooseHookTarget, new Card() { Suit = Suites.Chests, Value = 5 }); gameFixture.CurrentAvailableActions.Should().BeEquivalentTo( new List <Actions>() { Actions.ChooseHookTarget }); gameFixture.Field.Count.Should().Be(1); }
public void ChoosingATargetWithAnEffectTriggersThatEffect() { Game gameFixture = new Game(); Card FiveOfHooks = new Card() { Suit = Suites.Hooks, Value = 5 }; Card FiveOfCannons = new Card { Suit = Suites.Cannons, Value = 5 }; Card FiveOfKeys = new Card { Suit = Suites.Keys, Value = 5 }; GameHelpers.BringCardFromDeckToField(ref gameFixture, FiveOfHooks); GameHelpers.BringCardFromDeckToScoreZone(ref gameFixture, FiveOfCannons, 0); GameHelpers.BringCardFromDeckToScoreZone(ref gameFixture, FiveOfKeys, 1); GameHelpers.SetCurrentActions(ref gameFixture, new List <Actions> { Actions.ChooseHookTarget }); gameFixture.TakeAction(Actions.ChooseHookTarget, FiveOfCannons); gameFixture.CurrentAvailableActions.Should().BeEquivalentTo( new List <Actions>() { Actions.ChooseCannonTarget }); }
public static void blueColorStart() { GameHelpers.SpaceandClean(); Mana.myBlueColorMana(); GameHelpers.TextSpace(); Console.BackgroundColor = ConsoleColor.DarkBlue; Console.ForegroundColor = ConsoleColor.White; }
public static void blackStart() { GameHelpers.SpaceandClean(); BlackMana.myBlackMana(); GameHelpers.TextSpace(); Console.BackgroundColor = ConsoleColor.DarkGray; Console.ForegroundColor = ConsoleColor.Black; }
public static void whiteColorStart() { GameHelpers.SpaceandClean(); Mana.myWhiteManaColor(); GameHelpers.TextSpace(); Console.BackgroundColor = ConsoleColor.DarkYellow; Console.ForegroundColor = ConsoleColor.White; }
public static void greenColorStart() { GameHelpers.SpaceandClean(); Mana.myGreenManaColor(); GameHelpers.TextSpace(); Console.BackgroundColor = ConsoleColor.DarkGreen; Console.ForegroundColor = ConsoleColor.White; }
public static void redColorStart() { GameHelpers.SpaceandClean(); Mana.myRedManaColor(); GameHelpers.TextSpace(); Console.BackgroundColor = ConsoleColor.DarkRed; Console.ForegroundColor = ConsoleColor.White; }
public void OnCollisionEnter2D(Collision2D collision) { if (collision.collider.tag == StaticNames.Player && (keyManager.Use(KeyColor) || KeyColor == StandardColor.None)) { GameHelpers.LoadScene(levelSettings.NextScene); scoreObject.UpdateScore((Int32)GameHelpers.GetHUDLevelTimeLeft().GetRemainingTime() * 100); } }
public void Start() { keyManager = GameHelpers.GetHUDKeyManager(); SpriteRenderer spriteRenderer = gameObject.GetComponent <SpriteRenderer>(); Color color = Color.GetColor(); spriteRenderer.color = color; }
public void Test_CreateGame() { //A simple test to provide a troubleshooting entry point for the process of creating a game GameHelpers gh = new GameHelpers(); string errorMsg = ""; Game newGame = gh.CreateGame(1, "normal", out errorMsg); //string result = "1"; Assert.AreNotEqual(null, newGame, "New game was not created"); }