public CardData GetRandomCard() { var selectedIndex = (int)(_random.Randi() % _cards.Count); var cardDataJson = (Godot.Collections.Dictionary)_cards[selectedIndex]; var cardType = cardDataJson["type"].ToString(); var cardData = new CardData { Id = cardDataJson["id"].ToString(), Name = cardDataJson["name"].ToString(), Description = cardDataJson["description"].ToString(), Type = cardDataJson["type"].ToString(), Image = cardDataJson["image"].ToString(), }; if (cardType == nameof(CardType.Weapon)) { cardData = new WeaponCardData { Id = cardDataJson["id"].ToString(), Name = cardDataJson["name"].ToString(), Description = cardDataJson["description"].ToString(), Type = cardDataJson["type"].ToString(), Image = cardDataJson["image"].ToString(), Range = int.Parse(cardDataJson["range"].ToString()), Wide = int.Parse(cardDataJson["wide"].ToString()), }; } _graveyard.Add(cardDataJson); _cards.RemoveAt(selectedIndex); return(cardData); }
private void ReplaceWeapon(ulong playerInstanceID, WeaponCardData newWeapon, out WeaponCardData replacedWeapon) { var currentWeapon = GetPlayerWeapon(playerInstanceID); var playerItems = GetPlayerItems(playerInstanceID); playerItems.Remove(currentWeapon); playerItems.Add(newWeapon); _playerItems[playerInstanceID] = playerItems; replacedWeapon = currentWeapon; }
public void ProcessAttackOutput(string attackValue, WeaponCardData weaponData, Func <string, int> weaponDestroyed, Func <string, int> missed, Func <string, int> bodyShot, Func <string, int> headShot) { switch (attackValue) { case "Oops": weaponDestroyed("Your weapon has been destroyed!"); break; case "Miss": missed("You missed your shot!"); break; case "Bodyshot": bodyShot("Body shot!"); break; case "Headshot": headShot("Head shot!"); break; } }