public override void AddDelegate(CardEffectState cardEffectState, CardEffectParams cardEffectParams, DeckScreen deckScreen) { deckScreen.AddDeckScreenCardStateChosenDelegate((DeckScreen.CardStateChosenDelegate)(chosenCardState => { CardUpgradeState cardUpgradeState = new CardUpgradeState(); cardUpgradeState.Setup(cardEffectState.GetParamCardUpgradeData()); foreach (CardUpgradeMaskData filter in cardUpgradeState.GetFilters()) { if (!filter.FilterCard(chosenCardState, cardEffectParams.relicManager)) { // If any of the filters matches, it doesn't get upgraded return; } } if (chosenCardState.GetCardType() == CardType.Monster) { chosenCardState.GetTemporaryCardStateModifiers().AddUpgrade(cardUpgradeState); } if (chosenCardState.GetCardType() == CardType.Spell) { chosenCardState.AddTemporaryTrait(new CardTraitDataBuilder { TraitStateType = typeof(CardTraitPyreboost) }.Build(), cardEffectParams.cardManager); } chosenCardState.UpdateCardBodyText(); cardEffectParams.screenManager.SetScreenActive(ScreenName.Deck, false, (ScreenManager.ScreenActiveCallback)null); })); }
public static void LoadSaveState(StokerSaveState saveState, SaveManager save) { if (save != null && saveState != null) { //remove all cards except for champion var deckState = save.GetDeckState(); if (deckState != null) { deckState.RemoveAll(x => !x.IsChampionCard()); List <IDeckNotifications> deckNotifications = (List <IDeckNotifications>)AccessTools.Field(typeof(SaveManager), "deckNotifications").GetValue(save); deckNotifications.ForEach(rn => rn.DeckChangedNotification(deckState, save.GetVisibleDeckCount())); } save.RemoveAllRelics(); if (saveState.relics != null) { foreach (var relic in saveState.relics) { if (relic != null) { var relicData = save.GetAllGameData().FindCollectableRelicData(relic); if (relicData != null) { save.AddRelic(relicData); } } } } if (saveState.cards != null) { foreach (var card in saveState.cards) { if (card.cardName != null || card.cardName != "") { var cardData = save.GetAllGameData().FindCardData(card.cardName); var spawn = cardData.GetSpawnCharacterData(); if (cardData != null && (spawn == null || (spawn != null && !spawn.IsChampion()))) { var state = save.AddCardToDeck(cardData); if (card.upgradeNames != null) { foreach (string upgrade in card.upgradeNames) { if (upgrade != "") { CardUpgradeState cardUpgradeState = Activator.CreateInstance <CardUpgradeState>(); CardUpgradeData data = save.GetAllGameData().FindCardUpgradeData(upgrade); cardUpgradeState.Setup(data); state.Upgrade(cardUpgradeState, null); } } } } } } } } }
public override IEnumerator ApplyEffect(CardEffectState cardEffectState, CardEffectParams cardEffectParams) { foreach (CharacterState target in cardEffectParams.targets) { if (!OnGainEmber.energyData.TryGetValue(target, out int addEnergy)) { addEnergy = 1; } CardUpgradeState upgradeState = new CardUpgradeState(); upgradeState.Setup(cardEffectState.GetParamCardUpgradeData()); // Tweak the CardUpgradeState's stats Traverse.Create(upgradeState).Field("attackDamage").SetValue(upgradeState.GetAttackDamage() * addEnergy); Traverse.Create(upgradeState).Field("additionalHP").SetValue(upgradeState.GetAdditionalHP() * addEnergy); if (cardEffectParams.playedCard != null) { foreach (CardTraitState traitState in cardEffectParams.playedCard.GetTraitStates()) { traitState.OnApplyingCardUpgradeToUnit(cardEffectParams.playedCard, target, upgradeState, cardEffectParams.cardManager); } } int attackDamage = upgradeState.GetAttackDamage(); int additionalHP = upgradeState.GetAdditionalHP(); string text = ((attackDamage != 0) ? GetAttackNotificationText(upgradeState) : null); string text2 = ((additionalHP != 0) ? GetHPNotificationText(upgradeState) : null); string text3 = string.Empty; if (text != null && text2 != null) { text3 = string.Format("TextFormat_SpacedItems".Localize(), text, text2); } else if (text != null) { text3 = text; } else if (text2 != null) { text3 = text2; } if (text3 != null) { NotifyHealthEffectTriggered(cardEffectParams.saveManager, cardEffectParams.popupNotificationManager, text3, target.GetCharacterUI()); } yield return(target.ApplyCardUpgrade(upgradeState)); CardState spawnerCard = target.GetSpawnerCard(); bool flag = target.HasStatusEffect("cardless"); if (spawnerCard != null && !cardEffectParams.saveManager.PreviewMode && !flag) { CardAnimator.CardUpgradeAnimationInfo type = new CardAnimator.CardUpgradeAnimationInfo(spawnerCard, upgradeState); CardAnimator.DoAddRecentCardUpgrade.Dispatch(type); spawnerCard.GetTemporaryCardStateModifiers().AddUpgrade(upgradeState); spawnerCard.UpdateCardBodyText(); cardEffectParams.cardManager?.RefreshCardInHand(spawnerCard); } } }
public void AttemptToUpgradeCardState() { if (selectedCardState != null && selectedUpgradeData != null) { CardUpgradeState cardUpgradeState = Activator.CreateInstance <CardUpgradeState>(); cardUpgradeState.Setup(selectedUpgradeData); selectedCardState.Upgrade(cardUpgradeState, currentSave); selectedCardState.UpdateCardBodyText(currentSave); UpdateUpgrades(); RefreshSelectionCardStateSelectionButtons(); } }
public override IEnumerator ApplyEffect( CardEffectState cardEffectState, CardEffectParams cardEffectParams) { CardUpgradeState cardUpgradeState = new CardUpgradeState(); cardUpgradeState.Setup(cardEffectState.GetParamCardUpgradeData()); var card = cardEffectParams.playedCard; CardAnimator.CardUpgradeAnimationInfo type = new CardAnimator.CardUpgradeAnimationInfo(card, cardUpgradeState); CardAnimator.DoAddRecentCardUpgrade.Dispatch(type); card.GetTemporaryCardStateModifiers().AddUpgrade(cardUpgradeState); card.UpdateCardBodyText(); cardEffectParams.cardManager.RefreshCardInHand(card); yield break; }
public WardStatePower() { ID = "Power"; tooltipTitleKey = "PowerWardBeta_Name"; tooltipBodyKey = "PowerWardBeta_Desc"; var localPath = Path.GetDirectoryName(new Uri(Assembly.GetCallingAssembly().CodeBase).LocalPath); wardIcon = CustomAssetManager.LoadSpriteFromPath(Path.Combine(localPath, "Unit Assets/PowerWard.png")); CardUpgradeData upgrade = new CardUpgradeDataBuilder { BonusDamage = power }.Build(); upgradeState = new CardUpgradeState(); upgradeState.Setup(upgrade); }
public override void OnCardDrawn(CardState thisCard, CardManager cardManager, PlayerManager playerManager, MonsterManager monsterManager) { if (upgrade == null) { var upgradeBuilder = new CardUpgradeDataBuilder { HideUpgradeIconOnCard = true, }; upgradeBuilder.StatusEffectUpgrades.AddRange(GetParamStatusEffects().ToList()); upgrade = new CardUpgradeState(); upgrade.Setup(upgradeBuilder.Build()); } foreach (CardState item in cardManager.GetAllCards()) { if (item.IsMonsterCard() && !item.GetTemporaryCardStateModifiers().HasUpgrade(upgrade)) { item.GetTemporaryCardStateModifiers().AddUpgrade(upgrade); } } }
public override void AddDelegate(CardEffectState cardEffectState, CardEffectParams cardEffectParams, DeckScreen deckScreen) { deckScreen.AddDeckScreenCardStateChosenDelegate((DeckScreen.CardStateChosenDelegate)(chosenCardState => { CardUpgradeState cardUpgradeState = new CardUpgradeState(); cardUpgradeState.Setup(cardEffectState.GetParamCardUpgradeData()); foreach (CardUpgradeMaskData filter in cardUpgradeState.GetFilters()) { if (!filter.FilterCard(chosenCardState, cardEffectParams.relicManager)) { // If any of the filters matches, it doesn't get upgraded return; } } chosenCardState.GetTemporaryCardStateModifiers().AddUpgrade(cardUpgradeState); chosenCardState.UpdateCardBodyText(); cardEffectParams.screenManager.SetScreenActive(ScreenName.Deck, false, (ScreenManager.ScreenActiveCallback)null); })); }