private List <Item> GetAllShopItems() { using (var context = new BattleOfFaithsEntities()) { return(context.Items.ToList()); } }
private List <Character> GetAllCharacters() { using (var context = new BattleOfFaithsEntities()) { return(context.Characters.ToList()); } }
private int GetAmountOfMoney(Models.Game game) { using (var context = new BattleOfFaithsEntities()) { var currentGame = context.Games.FirstOrDefault(g => g.Id == game.Id); return(currentGame.Money); } }
private bool BagOver4(Models.Game game) { using (var context = new BattleOfFaithsEntities()) { var currentGame = context.Games.FirstOrDefault(g => g.Id == game.Id); return(currentGame.Items.Count >= 4); } }
private List <Character> GetAllGameCharacters(Models.Game game) { using (var context = new BattleOfFaithsEntities()) { var currentGame = context.Games.FirstOrDefault(g => g.Id == game.Id); return(currentGame.Characters.ToList()); } }
private Character GetCharacterFromFight(Fight fight) { using (var context = new BattleOfFaithsEntities()) { var currentFight = context.Fights.FirstOrDefault(f => f.Id == fight.Id); return(currentFight.Character); } }
private List <Models.Game> GetStartedGames() { using (var context = new BattleOfFaithsEntities()) { var games = context.Games.ToList(); return(games); } }
private List <Item> GetGameItems(Models.Game game) { using (var context = new BattleOfFaithsEntities()) { var currentGame = context.Games.FirstOrDefault(g => g.Id == game.Id); var items = currentGame.Items.Take(4).ToList(); return(items); } }
private int GetCharacterCharacteristicsByName(string type, Fight fight, string name) { using (var context = new BattleOfFaithsEntities()) { var currentFight = context.Fights.FirstOrDefault(f => f.Id == fight.Id); return(type == "fighter" ? (name == "health" ? currentFight.playerHealth : currentFight.playerMana) : (name == "health" ? currentFight.enemyHealth : currentFight.enemyMana)); } }
private int GetCharacterActionFrames(string type, Character character) { using (var context = new BattleOfFaithsEntities()) { var currentCharacter = context.Characters.FirstOrDefault(c => c.Id == character.Id); var currentActionFrames = currentCharacter.CharacterActions.FirstOrDefault(a => a.Name == type).Frames; return(currentActionFrames); } }
private void AddCharactersToGame(Models.Game game) { using (var context = new BattleOfFaithsEntities()) { var characters = context.Characters.ToList(); var currentGame = context.Games.FirstOrDefault(g => g.Id == game.Id); currentGame.Characters = characters; context.SaveChanges(); } }
private string GetCharacterActionSprite(string type, Character character) { using (var context = new BattleOfFaithsEntities()) { var currentCharacter = context.Characters.FirstOrDefault(c => c.Id == character.Id); var currentActionSprite = currentCharacter.CharacterActions.FirstOrDefault(a => a.Name == type).EnemySprite; return(currentActionSprite); } }
private void DecreaseMoney(int gameId, int price) { using (BattleOfFaithsEntities context = new BattleOfFaithsEntities()) { Models.Game game = context.Games.FirstOrDefault(g => g.Id == gameId); var leftMoney = game.Money - price; game.Money = leftMoney; context.SaveChanges(); } }
/// <summary> /// The main entry point for the application. /// </summary> static void Main(string[] args) { using (var context = new BattleOfFaithsEntities()) { context.Database.Initialize(true); } using (Game1 game = new Game1()) { game.Run(); } }
private void BuyIt(int itemId, int gameId) { using (BattleOfFaithsEntities context = new BattleOfFaithsEntities()) { Item item = context.Items.FirstOrDefault(i => i.Id == itemId); Models.Game game = context.Games.FirstOrDefault(g => g.Id == gameId); game.Items.Add(item); context.Games.Attach(game); context.SaveChanges(); } }
private string GetFighterData(Character character) { using (var context = new BattleOfFaithsEntities()) { var currentCharacter = context.Characters.FirstOrDefault(c => c.Id == character.Id); StringBuilder sb = new StringBuilder(); sb.AppendLine(currentCharacter.Name); sb.AppendLine($"Level: {currentCharacter.Level}"); //sb.AppendLine($"Highscore: {currentCharacter.Highscore}"); return(sb.ToString()); } }
private Models.Game CreateNewGame() { using (var context = new BattleOfFaithsEntities()) { Models.Game game = new Models.Game() { Date = DateTime.Now }; context.Games.Add(game); context.SaveChanges(); return(game); } }
private void SaveFightStatsToDatabase(Fight fight, Fighter fighter, Enemy enemy) { using (var context = new BattleOfFaithsEntities()) { var currentFight = context.Fights.FirstOrDefault(f => f.Id == fight.Id); var currentFighter = context.Characters.FirstOrDefault(c => c.Name == fighter.Character.Name); var currentEnemy = context.Characters.FirstOrDefault(c => c.Name == enemy.Character.Name); currentFight.playerHealth = playerHealth; currentFight.playerMana = playerMana; currentFight.enemyHealth = enemyHealth; currentFight.enemyMana = enemyMana; context.SaveChanges(); } }
private void SaveBagToDatabase(Models.Game game, List <GameItem> items) { using (var context = new BattleOfFaithsEntities()) { var currentGame = context.Games.FirstOrDefault(g => g.Id == game.Id); foreach (GameItem gi in items) { if (gi.IsUsed) { var item = context.Items.FirstOrDefault(i => i.Id == gi.Item.Id); currentGame.Items.Remove(item); } } context.SaveChanges(); } }
private int GetTotalHighscore(Models.Game game, Fighter fighter) { using (var context = new BattleOfFaithsEntities()) { var currentGame = context.Games.FirstOrDefault(g => g.Id == game.Id); var currentCharacter = currentGame.Characters.FirstOrDefault(c => c.Id == fighter.Character.Id); var currentLevel = currentCharacter.Level; var level = 0; var currentHighscore = currentCharacter.Highscore + int.Parse(this.highscoreMade); if (currentHighscore > 4000) { level = 5; } else if (currentHighscore > 3000) { level = 4; } else if (currentHighscore > 2000) { level = 3; } else if (currentHighscore > 1000) { level = 2; } else if (currentHighscore > 500) { level = 1; } if (currentLevel < level) { levelUp = true; currentCharacter.Level += 1; moneyWon = (int.Parse(moneyWon) + currentCharacter.Level * 500).ToString(); } currentCharacter.Highscore += int.Parse(this.highscoreMade); currentGame.Money += int.Parse(moneyWon); currentGame.HighScore += int.Parse(this.highscoreMade); context.SaveChanges(); return(currentCharacter.Level); } }
private string TakeBestGames() { using (var context = new BattleOfFaithsEntities()) { var result = context.Games .OrderByDescending(g => g.HighScore) .Select(g => new { Date = g.Date, HighScore = g.HighScore }).Take(3).ToList(); StringBuilder sb = new StringBuilder(); sb.AppendLine("Best Games Highscore :"); int count = 0; foreach (var ch in result) { sb.AppendLine($"{++count}. {ch.Date} : {ch.HighScore}"); } return(sb.ToString()); } }
private string TakeBestChar() { using (var context = new BattleOfFaithsEntities()) { var result = context.Characters .OrderByDescending(c => c.Highscore) .Select(c => new { Name = c.Name, Highscore = c.Highscore }).ToList(); StringBuilder sb = new StringBuilder(); sb.AppendLine("Best Characters Highscore :"); int count = 0; foreach (var ch in result) { sb.AppendLine($"{++count}. {ch.Name} : {ch.Highscore}"); } return(sb.ToString()); } }
private void FillFightCharacteristics(Fight fight, Fighter fighter, Enemy enemy) { using (var context = new BattleOfFaithsEntities()) { var currentFight = context.Fights.FirstOrDefault(f => f.Id == fight.Id); var currentFighter = context.Characters.FirstOrDefault(c => c.Name == fighter.Character.Name); var currentEnemy = context.Characters.FirstOrDefault(c => c.Name == enemy.Character.Name); currentFight.playerHealth = currentFighter.Health * (currentFighter.Level + 2); currentFight.playerMana = currentFighter.Mana * (currentFighter.Level + 2); currentFight.playerAtkDmg = currentFighter.Attack * (currentFighter.Level + 1); currentFight.playerSpAtkDmg = currentFighter.SpecAttack * (currentFighter.Level + 1); currentFight.enemyHealth = currentEnemy.Health * (currentFighter.Level + 2); currentFight.enemyMana = currentEnemy.Mana * (currentFighter.Level + 2); currentFight.enemyAtkDmg = currentEnemy.Attack * (currentFighter.Level + 1); currentFight.enemySpAtkDmg = currentEnemy.SpecAttack * (currentFighter.Level + 1); context.SaveChanges(); } }
private Fight CreateCurrentFight(Character character, Models.Game game) { using (var context = new BattleOfFaithsEntities()) { var currentGame = context.Games.FirstOrDefault(g => g.Id == game.Id); var currentCharacter = context.Characters.FirstOrDefault(c => c.Id == character.Id); var fight = new Fight() { CharacterId = currentCharacter.Id, GameId = currentGame.Id }; currentGame.Fights.Add(fight); context.Games.Attach(currentGame); context.SaveChanges(); return(fight); }; }
private int GetStats(Fight fight, string type) { using (var context = new BattleOfFaithsEntities()) { var currentFight = context.Fights.FirstOrDefault(f => f.Id == fight.Id); switch (type) { case "playerHealth": return(currentFight.playerHealth); case "playerMana": return(currentFight.playerMana); case "playerAtk": return(currentFight.playerAtkDmg); case "playerSpAtk": return(currentFight.playerSpAtkDmg); case "enemyHealth": return(currentFight.enemyHealth); case "enemyMana": return(currentFight.enemyMana); case "enemyAtk": return(currentFight.enemyAtkDmg); case "enemySpAtk": return(currentFight.enemySpAtkDmg); default: return(0); } } }