public bool CharacterMeetsCardRequirements(CombatCard card) { if (!hasTurn) return false; int staminaReq; if (card.useUpAllStamina) staminaReq = 1; else staminaReq = card.staminaCost; int ammoReq = card.ammoCost; if (card.GetType().BaseType==typeof(MeleeCard) && meleeAttacksAreFree) staminaReq = 0; if (card.GetType().BaseType == typeof(RangedCard)) { if (rangedAttacksAreFree) ammoReq = 0; else { ammoReq = Mathf.Max(0,ammoReq-rangedAttacksAmmoCostReduction); if (rangedAttacksCostStamina) { staminaReq += ammoReq; ammoReq = 0; } } } if (GetStamina() < staminaReq) return false; if (GetAmmo() < ammoReq) return false; if (!card.SpecialPrerequisitesMet(this)) return false; return true; }
public bool IsCardBlocked(CombatCard card) { if (card.GetType() == typeof(MeleeCard) && meleeBlockActive) return true; if (card.GetType() == typeof(RangedCard) && rangedBlockActive) return true; return false; }
public void AssignCardTargets(CombatCard playedCard, CharacterGraphic selectedCharacter) { List<CharacterGraphic> opposingGroup; List<CharacterGraphic> friendlyGroup; if (combatManager.GetTurnStatus() == CombatManager.TurnStatus.Player) { opposingGroup = characterManager.GetEnemyGraphics(); friendlyGroup = characterManager.GetMercGraphics(); } else { opposingGroup = characterManager.GetMercGraphics(); friendlyGroup = characterManager.GetEnemyGraphics(); } if (playedCard.targetType == CombatCard.TargetType.None) { return; } //The following two are usually only used by the AI (unless a melee override target is set) if (playedCard.targetType == CombatCard.TargetType.SelectEnemy) { playedCard.targetChars.Add(opposingGroup[Random.Range(0, opposingGroup.Count)]); } if (playedCard.targetType == CombatCard.TargetType.SelectFriendly) { playedCard.targetChars.Add(friendlyGroup[Random.Range(0, friendlyGroup.Count)]); } if (playedCard.targetType == CombatCard.TargetType.SelectFriendlyOther) { List<CharacterGraphic> friendlyOthers = new List<CharacterGraphic>(friendlyGroup); friendlyOthers.Remove(selectedCharacter); playedCard.targetChars.Add(friendlyOthers[Random.Range(0, friendlyOthers.Count)]); } if (playedCard.targetType == CombatCard.TargetType.Random) { playedCard.targetChars.Add(opposingGroup[Random.Range(0, opposingGroup.Count)]); } if (playedCard.targetType == CombatCard.TargetType.AllEnemies) { playedCard.targetChars.AddRange(opposingGroup); } if (playedCard.targetType == CombatCard.TargetType.AllFriendlies) { playedCard.targetChars.AddRange(friendlyGroup); } if (playedCard.targetType == CombatCard.TargetType.Weakest) { CharacterGraphic weakestCharGraphic = opposingGroup[0]; foreach (CharacterGraphic charGraphic in opposingGroup) { if (charGraphic.GetEffectiveHitpoints() == weakestCharGraphic.GetEffectiveHitpoints()) { if (Random.value < 0.5f) weakestCharGraphic = charGraphic; } else { if (charGraphic.GetEffectiveHitpoints() < weakestCharGraphic.GetEffectiveHitpoints()) weakestCharGraphic = charGraphic; } } playedCard.targetChars.Add(weakestCharGraphic); } if (playedCard.targetType == CombatCard.TargetType.Strongest) { CharacterGraphic strongestCharGraphic = opposingGroup[0]; foreach (CharacterGraphic charGraphic in opposingGroup) { if (charGraphic.GetEffectiveHitpoints() == strongestCharGraphic.GetEffectiveHitpoints()) { if (Random.value < 0.5f) strongestCharGraphic = charGraphic; } else { if (charGraphic.GetEffectiveHitpoints() > strongestCharGraphic.GetEffectiveHitpoints()) strongestCharGraphic = charGraphic; } } playedCard.targetChars.Add(strongestCharGraphic); } if (playedCard.GetType().BaseType == typeof(MeleeCard)) TryOverrideMeleeCardTarget(playedCard); if (playedCard.GetType().BaseType == typeof(RangedCard)) TryOverrideRangedCardTarget(playedCard); }