Made the Battle Factory work

This commit is contained in:
Maruno17
2021-05-15 17:38:16 +01:00
parent e350cb8f4a
commit f303b84033
6 changed files with 160 additions and 158 deletions

View File

@@ -19,18 +19,20 @@ class BattleChallenge
@id = id
@numRounds = numrounds
@rules = rules
register(id, id[/double/], 3,
id[/^factory/] ? BattleFactoryID : BattleTowerID,
id[/open$/] ? 1 : 0)
pbWriteCup(id, rules)
end
def register(id, doublebattle, numrounds, numPokemon, battletype, mode = 1)
def register(id, doublebattle, numPokemon, battletype, mode = 1)
ensureType(id)
if battletype == BattleFactoryID
@bc.setExtraData(BattleFactoryData.new(@bc))
numPokemon = 3
battletype = BattleTowerID
end
@numRounds = numrounds
@rules = modeToRules(doublebattle, numPokemon, battletype, mode)
@rules = modeToRules(doublebattle, numPokemon, battletype, mode) if !@rules
end
def rules
@@ -371,7 +373,7 @@ class BattleFactoryData
def pbPrepareRentals
@rentals = pbBattleFactoryPokemon(pbBattleChallenge.rules, @bcdata.wins, @bcdata.swaps, [])
@trainerid = @bcdata.nextTrainer
bttrainers = pbGetBTTrainers(@bcdata.currentChallenge)
bttrainers = pbGetBTTrainers(pbBattleChallenge.currentChallenge)
trainerdata = bttrainers[@trainerid]
@opponent = NPCTrainer.new(
pbGetMessageFromHash(MessageTypes::TrainerNames, trainerdata[1]),
@@ -386,19 +388,19 @@ class BattleFactoryData
screen = BattleSwapScreen.new(scene)
@rentals = screen.pbStartRent(@rentals)
@bcdata.pbAddSwap
pbBattleChallenge.setParty(@rentals)
@bcdata.setParty(@rentals)
}
end
def pbPrepareSwaps
@oldopponent = @opponent.party
trainerid = @bcdata.nextTrainer
bttrainers = pbGetBTTrainers(@bcdata.currentChallenge)
bttrainers = pbGetBTTrainers(pbBattleChallenge.currentChallenge)
trainerdata = bttrainers[trainerid]
@opponent = NPCTrainer.new(
pbGetMessageFromHash(MessageTypes::TrainerNames, trainerdata[1]),
trainerdata[0])
opponentPkmn = pbBattleFactoryPokemon(challenge.rules, @bcdata.wins, @bcdata.swaps,
opponentPkmn = pbBattleFactoryPokemon(pbBattleChallenge.rules, @bcdata.wins, @bcdata.swaps,
[].concat(@rentals).concat(@oldopponent))
@opponent.party = opponentPkmn.shuffle[0, 3]
end
@@ -416,7 +418,7 @@ class BattleFactoryData
end
def pbBattle(challenge)
bttrainers = pbGetBTTrainers(@bcdata.currentChallenge)
bttrainers = pbGetBTTrainers(pbBattleChallenge.currentChallenge)
trainerdata = bttrainers[@trainerid]
return pbOrganizedBattleEx(@opponent, challenge.rules,
pbGetMessageFromHash(MessageTypes::EndSpeechLose, trainerdata[4]),