public bool fetchPlayerInfo() { using (var db = new Model.soulsEntities()) { // TODO this. var dbPlayer = db.db_Player_Hash.FirstOrDefault(x => x.hash == hash).db_Player; this.id = dbPlayer.id; this.name = dbPlayer.name; this.rank = dbPlayer.rank; if (dbPlayer != null) return true; else return false; } }
public List<Card> LoadCards() { using (var db = new Model.soulsEntities()) { Stopwatch w = new Stopwatch(); w.Start(); List<Card> cards = db.db_Card .Join( db.db_Ability, card => card.fk_ability, ability => ability.id, (card, ability) => new { card, ability } ) .Join( db.db_Card_Type, y => y.card.fk_type, cType => cType.id, (y, cType) => new { y, cType } ).Select(x => new Card() { id = x.y.card.id, name = x.y.card.name, attack = x.y.card.attack, health = x.y.card.health, armor = x.y.card.armor, cost = x.y.card.cost, ability = new Ability() { id = x.y.ability.id, name = x.y.ability.name, parameter = x.y.ability.parameter }, cardType = new CardType() { id = x.y.ability.id, name = x.y.ability.name, }, }).AsParallel().ToList(); Console.WriteLine(">[GAME] Loaded " + cards.Count() + " cards, Took: " + w.ElapsedMilliseconds); w.Stop(); return cards; } }
public bool ValidateHash() { using (var db = new Model.soulsEntities()) { var hashExists = (from b in db.db_Player_Hash where b.hash == hash select b).FirstOrDefault(); if (hashExists != null) return true; else return false; } }
/// <summary> /// This fetches the newest hash available for the player //TODO this may fail? Make a gameList with all the hashes ? NEED TEST /// </summary> /// <returns></returns> public string UpdateHash() { using (var db = new Model.soulsEntities()) { var dbPlayer = db.db_Player_Hash.FirstOrDefault(x => x.fk_player_id == id); if(!this.hash.Equals(dbPlayer.hash)) { Console.WriteLine("New hash found, updating!"); this.hash = dbPlayer.hash; } } return this.hash; // This will always be either the same or a new one (Same would be "updated" if no new was found) }