private void CalculateAttackCard(TempPlayer player) { AttackCard card = Constants.attackCards[player.selectedCardID]; //Add initiative if player was first if (player.initiative && card.initiativeEffect != Constants.NoEffectID) { if (Constants.effects[card.initiativeEffect].selfEffect == 0) { TempPlayer enemy = player == p1 ? p2 : p1; enemy.AddEffect(card.initiativeEffect, card.initiativeValue, card.initiativeDuration); } else { player.AddEffect(card.initiativeEffect, card.initiativeValue, card.initiativeDuration); } } //Save temp results for match player.results.dmgPerBullet = card.damage; player.results.bulletsSpent = card.bullets; player.results.accuracy += card.accuracy; //+ because default value for accuracy is 100 //DETECT Other player for shooting TempPlayer other = player == p1 ? p2 : p1; switch (player.bodyPart) { case "Head": player.AddEffect(Constants.ShootInHeadEffectID, 0, 0); break; case "Arm": player.AddEffect(Constants.ShootInArmEffectID, 0, 0); break; case "Leg": player.AddEffect(Constants.ShootInLegEffectID, 0, 0); break; case "Body": player.AddEffect(Constants.ShootInBodyEffectID, 0, 0); break; } //Use PrefEffects player.UseEffects(true); player.MakeShots(other); //Use Post Effects player.UseEffects(false); }
public static Dictionary <int, AttackCard> GetAllAttackCards() { var result = new Dictionary <int, AttackCard>(); var query = "SELECT * from attack_cards"; var connection = new MySqlConnection(MySQL.CreateConnectionString()); connection.Open(); var cmd = new MySqlCommand(query, connection); MySqlDataReader reader; try { reader = cmd.ExecuteReader(); } catch (Exception ex) { Console.WriteLine(ex.ToString()); throw; } while (reader.Read()) { AttackCard tempCard = new AttackCard(); tempCard.id = (int)(uint)reader["id"]; tempCard.type = "Attack"; tempCard.damage = (int)reader["damage"]; tempCard.bullets = (int)reader["bullets"]; tempCard.accuracy = (int)reader["accuracy"]; tempCard.name = (string)reader["name"]; tempCard.image = (string)reader["image"]; tempCard.initiativeEffect = (int)reader["initiativeEffectID"]; tempCard.initiativeValue = (int)reader["initiativeValue"]; tempCard.initiativeDuration = (int)reader["initiativeDuration"]; result[tempCard.id] = tempCard; } reader.Close(); connection.Close(); return(result); }