public void CheckIsBattleOver() { QueuedActions.ImmediateAction("CheckIsBattleOver", () => { BattleRules.CheckIsBattleOverAndIfSoSwitchScenes(); }); }
// Called by the game to create an instance of this event. // Note: This constructor should not be available in the API. internal BattleStartedEvent(BattleRules battleRules, int robotsCount, bool isReplay) : base() { this.battleRules = battleRules; this.isReplay = isReplay; this.robotsCount = robotsCount; }
public static void CheckAndRegisterDeath(AbstractBattleUnit unit, AbstractBattleUnit nullableUnitThatKilledMe, AbstractCard cardUsedIfAny) { if (unit.HasDied) { /// stopping this from triggering more than once on a unit return; } if (unit.CurrentHp <= 0) { unit.HasDied = true; ActionManager.Instance.TriggerUnitKilledFeedback(unit); foreach (var effect in unit.StatusEffects) { effect.OnDeath(nullableUnitThatKilledMe, cardUsedIfAny); } BattleRules.TriggerProc(new CharacterDeathProc { CharacterDead = unit }); foreach (var card in GameState.Instance.Deck.TotalDeckList) { if (card.Owner == unit) { // we always exhaust all cards owned by dead people. ActionManager.Instance.ExhaustCard(card); } } } }
internal void CreateCardToBattleDeckDiscardPile(AbstractCard abstractCard, AbstractBattleUnit owner = null, CardCreationLocation location = CardCreationLocation.SHUFFLE, QueueingType queueingType = QueueingType.TO_BACK) { Require.NotNull(abstractCard); abstractCard.Owner = owner; QueuedActions.ImmediateAction("CreateCardToBattleDeckDiscardPile", () => { BattleRules.MarkCreatedCard(abstractCard, owner); if (location == CardCreationLocation.BOTTOM) { ServiceLocator.GameState().Deck.DiscardPile.Add(abstractCard); } else if (location == CardCreationLocation.TOP) { ServiceLocator.GameState().Deck.DiscardPile.AddToFront(abstractCard); } else if (location == CardCreationLocation.SHUFFLE) { ServiceLocator.GameState().Deck.DiscardPile.InsertIntoRandomLocation(abstractCard); } else { throw new Exception("gotta select a location"); } }, queueingType); }
public RobotStatics(string robocodeVersion, bool isJuniorRobot, bool isInteractiveRobot, bool isPaintRobot, bool isAdvancedRobot, bool isTeamRobot, bool isTeamLeader, bool isDroid, bool isSentryRobot, string name, string shortName, string veryShortName, string fullClassName, string shortClassName, BattleRules battleRules, string[] teammates, string teamName, int index, int contestantIndex) { this.robocodeVersion = robocodeVersion; this.isJuniorRobot = isJuniorRobot; this.isAdvancedRobot = isAdvancedRobot; this.isTeamRobot = isTeamRobot; this.isDroid = isDroid; this.isSentryRobot = isSentryRobot; this.isInteractiveRobot = isInteractiveRobot; this.isPaintRobot = isPaintRobot; this.isTeamLeader = isTeamLeader; this.name = name; this.shortName = shortName; this.veryShortName = veryShortName; this.fullClassName = fullClassName; this.shortClassName = shortClassName; this.battleRules = battleRules; this.teammates = teammates; this.teamName = teamName; this.index = index; this.contestantIndex = contestantIndex; }
public object deserialize(RbSerializerN serializer, ByteBuffer buffer) { bool isJuniorRobot = serializer.deserializeBoolean(buffer); bool isInteractiveRobot = serializer.deserializeBoolean(buffer); bool isPaintRobot = serializer.deserializeBoolean(buffer); bool isAdvancedRobot = serializer.deserializeBoolean(buffer); bool isTeamRobot = serializer.deserializeBoolean(buffer); bool isTeamLeader = serializer.deserializeBoolean(buffer); bool isDroid = serializer.deserializeBoolean(buffer); string name = serializer.deserializeString(buffer); string shortName = serializer.deserializeString(buffer); string veryShortName = serializer.deserializeString(buffer); string fullClassName = serializer.deserializeString(buffer); string shortClassName = serializer.deserializeString(buffer); BattleRules battleRules = HiddenAccessN.createRules( serializer.deserializeInt(buffer), serializer.deserializeInt(buffer), serializer.deserializeInt(buffer), serializer.deserializeDouble(buffer), serializer.deserializeLong(buffer) ); var teammates = new List <string>(); object item = serializer.deserializeString(buffer); while (item != null) { if (item is string) { teammates.Add((string)item); } item = serializer.deserializeString(buffer); } string teamName = serializer.deserializeString(buffer); int index = serializer.deserializeInt(buffer); int contestantIndex = serializer.deserializeInt(buffer); return(new RobotStatics( isJuniorRobot, isInteractiveRobot, isPaintRobot, isAdvancedRobot, isTeamRobot, isTeamLeader, isDroid, name, shortName, veryShortName, fullClassName, shortClassName, battleRules, teammates.ToArray(), teamName, index, contestantIndex )); }
public void KillUnit(AbstractBattleUnit unit) { QueuedActions.ImmediateAction("KillUnit", () => { unit.CurrentHp = 0; BattleRules.CheckAndRegisterDeath(unit, null, null); }); }
public void Slay(AbstractCard damageSource, AbstractBattleUnit target) { var slew = SlayInner(damageSource, target); if (slew) { BattleRules.TriggerProc(new LethalTriggerProc()); } }
public static void Sly(this AbstractCard card, Action thingToDo) { if (state.Deck.Hand.Count < 3) { thingToDo(); BattleRules.TriggerProc(new SlyProc { TriggeringCardIfAny = card }); } }
public static void Inferno(this AbstractCard card, Action thingToDo) { var burningEnemy = state.EnemyUnitsInBattle.Any(enemy => !enemy.IsDead && enemy.HasStatusEffect <BurningStatusEffect>()); { thingToDo(); BattleRules.TriggerProc(new InfernoProc { TriggeringCardIfAny = card }); } }
private string GetDisplayedRetaliateDamage() { if (OwnerUnit == null) { return(""); } var damageToReturn = BattleRules.GetAnticipatedDamageToUnit(OwnerUnit, null, 5, true, null); return($"[Will deal {damageToReturn} per hit before enemy modifiers]"); }
public void ApplyDefense(AbstractBattleUnit target, AbstractBattleUnit source, int baseQuantity) { QueuedActions.ImmediateAction("ApplyDefense", () => { target.CurrentBlock += BattleRules.GetDefenseApplied(source, target, baseQuantity); if (target.CurrentBlock < 0) { target.CurrentBlock = 0; } }); }
public override CanPlayCardQueryResult CanPlayInner(AbstractBattleUnit target) { if (BattleRules.IsEnemyEligibleForTaunting(target, this.Owner)) { return(CanPlayCardQueryResult.CanPlay()); } else { return(CanPlayCardQueryResult.CannotPlay("Taunted units must be attacking exactly one" + " target who is not the taunting character.")); } }
public static void Brute(this AbstractCard card, Action thingToDo) { var cost3Card = state.Deck.Hand.FirstOrDefault(c => c.BaseEnergyCost() == 3); if (cost3Card != null) { thingToDo(); BattleRules.TriggerProc(new BruteProc { TriggeringCardIfAny = card }); } }
public override void OnStruck(AbstractBattleUnit unitStriking, AbstractCard cardUsedIfAny, int totalDamageTaken) { if (Stacks <= 0) { return; } var damageToReturn = BattleRules.GetAnticipatedDamageToUnit(OwnerUnit, unitStriking, 5, true, null); var enhancerStacks = unitStriking.GetStatusEffect <GentleDiscouragementStatusEffect>()?.Stacks ?? 0; action().DamageUnitNonAttack(unitStriking, null, damageToReturn + enhancerStacks); Stacks--; }
public void ExhaustCard(AbstractCard protoCard, QueueingType queueingType = QueueingType.TO_BACK) { QueuedActions.DelayedActionWithCustomTrigger("ExhaustCard", () => { gameState.Deck.MoveCardToPile(protoCard, CardPosition.EXPENDED); ServiceLocator.GetCardAnimationManager().DisappearCard(protoCard, assumedToExistInHand: false, callbackWhenFinished: () => { IsCurrentActionFinished = true; }); BattleRules.TriggerProc(new ExhaustedCardProc { TriggeringCardIfAny = protoCard }); }, queueingType); }
public static void Sacrifice(this AbstractCard card, Action thingToDo) { var sacrificableCard = state.Deck.Hand.FirstOrDefault(item => item != card); if (sacrificableCard != null) { sacrificableCard.Action_Exhaust(); action.ApplyStress(sacrificableCard.Owner, 6); BattleRules.TriggerProc(new SacrificeProc { TriggeringCardIfAny = card }); thingToDo(); } }
public static void Liquidate(this AbstractCard card, Action thingToDo) { var firstRareCard = state.Deck.Hand.FirstOrDefault(item => item.Rarity == Rarity.RARE && item != card); if (firstRareCard != null) { thingToDo(); action.ExhaustCard(firstRareCard); BattleRules.TriggerProc(new LiquidateProc { TriggeringCardIfAny = card }); } }
public BattleState(BattleRules battleRules, EntityState entity1, EntityState entity2) { BattleRules = battleRules; Tags = new TagCollection(this); m_entity1 = entity1; m_entity2 = entity2; m_nextActions = new Dictionary <Guid, string>(); foreach (EntityState entity in AllEntities()) { entity.JoinBattle(this); } StartBattle(); }
internal void CreateCardToHand(AbstractCard abstractCard, AbstractBattleUnit owner = null, QueueingType queueingType = QueueingType.TO_BACK) { Require.NotNull(abstractCard); abstractCard.Owner = owner; QueuedActions.ImmediateAction("CreateCardToHand", () => { BattleRules.MarkCreatedCard(abstractCard, owner); ServiceLocator.GameState().Deck.Hand.Add(abstractCard); ServiceLocator.GetCardAnimationManager().AddHypercardsToHand(new List <Card> { abstractCard.CreateHyperCard() }); }, queueingType); }
public void AdvanceOrRetreatAsAppropriate() { if (BattleRules.CanAdvance(battleUnit)) { ActionManager.Instance.PerformAdvanceActionIfPossible(battleUnit); } else if (BattleRules.CanFallBack(battleUnit)) { ActionManager.Instance.PerformFallbackActionIfPossible(battleUnit); } else { ActionManager.Instance.Shout(battleUnit, "I can neither advance nor fall back!"); } }
public void PlayCardFromHandIfAble_Action(AbstractBattleUnit target) { if (!CanPlay(target).Playable) { return; } var costPaid = BattleRules.ProcessPlayingCardCost(this); EvokeCardEffect(target, costPaid); BattleRules.RunOnPlayCardEffects(this, target, costPaid); if (state().Deck.Hand.Contains(this)) { state().Deck.MoveCardToPile(this, CardPosition.DISCARD); ServiceLocator.GetCardAnimationManager().MoveCardToDiscardPile(this, assumedToExistInHand: true); } state().cardsPlayedThisTurn += 1; }
public void AttackUnitForDamage(AbstractBattleUnit targetUnit, AbstractBattleUnit sourceUnit, int baseDamageDealt, AbstractCard cardPlayed) { Require.NotNull(targetUnit); QueuedActions.DelayedActionWithCustomTrigger("AttackUnitForDamage_ShakeUnit", () => { if (targetUnit.IsDead || sourceUnit.IsDead) { // do nothing if it's already dead IsCurrentActionFinished = true; return; } targetUnit.CorrespondingPrefab.gameObject.AddComponent <ShakePrefab>(); var shakePrefab = targetUnit.CorrespondingPrefab.gameObject.GetComponent <ShakePrefab>(); shakePrefab.Begin(() => { IsCurrentActionFinished = true; }); targetUnit.CorrespondingPrefab.FlickerFeedbacks.PlayFeedbacks(); BattleRules.ProcessDamageWithCalculatedModifiers(sourceUnit, targetUnit, cardPlayed, baseDamageDealt); }); }
protected void SendMessageToFirstValidMouseButtonUpHandler(Vector2 position) { var elements = GetAllUIElements(position); if (elements == null) { return; } if (SelectCardInHandOverlay.INSTANCE.IsCardSelectBehaviorActive) { foreach (var element in elements) { var cardUiBehaviorNullable = element.GetComponent <CardUiBehaviors>(); if (cardUiBehaviorNullable != null) { var card = cardUiBehaviorNullable.GetComponent <Card>(); card.IsSelected = !card.IsSelected; CardAnimationManager.INSTANCE.ReorientAllCards(); SelectCardInHandOverlay.INSTANCE.ExecuteClickingOnCard(cardUiBehaviorNullable); } } return; } foreach (var element in elements) { if (element.GetComponent <CardUiBehaviors>() != null) { // We're ignoring any case where we release the mouse button over a card return; } var battleUnitMousedOver = element.GetComponent <BattleUnitPrefab>(); var battleUnitTargeted = battleUnitMousedOver?.UnderlyingEntity; BattleRules.ProcessUiReleasingCardOverBattleUnit(logicalCard, battleUnitTargeted); if (element.GetComponent <CardPlayArea>() != null && logicalCard.TargetType == TargetType.NO_TARGET_OR_SELF) { ActionManager.Instance.AttemptPlayCardFromHand(this.logicalCard, null); } } ServiceLocator.GameState().UnselectCard(); }
public void DamageUnitNonAttack(AbstractBattleUnit targetUnit, AbstractBattleUnit nullableSourceUnit, int baseDamageDealt) { if (targetUnit == null) { return; } QueuedActions.DelayedActionWithCustomTrigger("DamageUnitNonAttack_ShakeUnit", () => { if (targetUnit.IsDead) { // do nothing if it's already dead IsCurrentActionFinished = true; return; } targetUnit.CorrespondingPrefab.gameObject.AddComponent <ShakePrefab>(); var shakePrefab = targetUnit.CorrespondingPrefab.gameObject.GetComponent <ShakePrefab>(); shakePrefab.Begin(() => { IsCurrentActionFinished = true; }); targetUnit.CorrespondingPrefab.FlickerFeedbacks.PlayFeedbacks(); BattleRules.ProcessDamageWithCalculatedModifiers(nullableSourceUnit, targetUnit, nullableCardPlayed: null, baseDamage: baseDamageDealt, isAttack: false); }); }
public int DisplayedDamage(int?baseDamageOverride = null) { return(BattleRules.GetDisplayedDamageOnCard(this, baseDamageOverride)); }
public int DisplayedDefense() { return(BattleRules.GetDisplayedDefenseOnCard(this)); }
public int displayedDamage() { return(BattleRules.GetDisplayedDamageOnCard(this)); }
// Called by the game to create an instance of this event. // Note: This constructor should not be available in the API. internal BattleCompletedEvent(BattleRules battleRules, BattleResults[] results) : base() { this.battleRules = battleRules; this.results = results; }
public object deserialize(RbSerializerN serializer, ByteBuffer buffer) { string robocodeVersion = serializer.deserializeString(buffer); bool isJuniorRobot = serializer.deserializeBoolean(buffer); bool isInteractiveRobot = serializer.deserializeBoolean(buffer); bool isPaintRobot = serializer.deserializeBoolean(buffer); bool isAdvancedRobot = serializer.deserializeBoolean(buffer); bool isTeamRobot = serializer.deserializeBoolean(buffer); bool isTeamLeader = serializer.deserializeBoolean(buffer); bool isDroid = serializer.deserializeBoolean(buffer); bool isSentryRobot = serializer.deserializeBoolean(buffer); string name = serializer.deserializeString(buffer); string shortName = serializer.deserializeString(buffer); string veryShortName = serializer.deserializeString(buffer); string fullClassName = serializer.deserializeString(buffer); string shortClassName = serializer.deserializeString(buffer); BattleRules battleRules = HiddenAccessN.createRules( serializer.deserializeInt(buffer), // BattlefieldWidth serializer.deserializeInt(buffer), // BattlefieldHeight serializer.deserializeInt(buffer), // NumRounds serializer.deserializeDouble(buffer), // GunCoolingRate serializer.deserializeLong(buffer), // InactivityTime serializer.deserializeBoolean(buffer), // HideEnemyNames serializer.deserializeInt(buffer) // SentryBorderSize ); var teammates = new List <string>(); object item = serializer.deserializeString(buffer); while (item != null) { if (item is string) { teammates.Add((string)item); } item = serializer.deserializeString(buffer); } string teamName = serializer.deserializeString(buffer); int index = serializer.deserializeInt(buffer); int contestantIndex = serializer.deserializeInt(buffer); return(new RobotStatics( robocodeVersion, isJuniorRobot, isInteractiveRobot, isPaintRobot, isAdvancedRobot, isTeamRobot, isTeamLeader, isDroid, isSentryRobot, name, shortName, veryShortName, fullClassName, shortClassName, battleRules, teammates.ToArray(), teamName, index, contestantIndex )); }