mirror of
https://github.com/infinitefusion/infinitefusion-e18.git
synced 2025-12-09 14:14:59 +00:00
Added support for the Bug Catching Contest taking place over multiple maps
This commit is contained in:
@@ -24,10 +24,11 @@ class BugContestState
|
|||||||
@lastContest = nil
|
@lastContest = nil
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Returns whether the last contest ended less than 24 hours ago.
|
||||||
def pbContestHeld?
|
def pbContestHeld?
|
||||||
return false if !@lastContest
|
return false if !@lastContest
|
||||||
timenow = pbGetTimeNow
|
timenow = pbGetTimeNow
|
||||||
return timenow.to_i - @lastContest < 86_400
|
return timenow.to_i - @lastContest < 24 * 60 * 60 # 24 hours
|
||||||
end
|
end
|
||||||
|
|
||||||
def expired?
|
def expired?
|
||||||
@@ -39,17 +40,17 @@ class BugContestState
|
|||||||
end
|
end
|
||||||
|
|
||||||
def clear
|
def clear
|
||||||
@ballcount = 0
|
@ballcount = 0
|
||||||
@ended = false
|
@ended = false
|
||||||
@inProgress = false
|
@inProgress = false
|
||||||
@decision = 0
|
@decision = 0
|
||||||
@encounterMap = 0
|
@lastPokemon = nil
|
||||||
@lastPokemon = nil
|
@otherparty = []
|
||||||
@otherparty = []
|
@contestants = []
|
||||||
@contestants = []
|
@places = []
|
||||||
@places = []
|
@start = nil
|
||||||
@start = nil
|
@contestMaps = []
|
||||||
@reception = []
|
@reception = []
|
||||||
end
|
end
|
||||||
|
|
||||||
def inProgress?
|
def inProgress?
|
||||||
@@ -68,21 +69,19 @@ class BugContestState
|
|||||||
@chosenPokemon = chosenpoke
|
@chosenPokemon = chosenpoke
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def pbSetContestMap(*maps)
|
||||||
|
@contestMaps = maps
|
||||||
|
end
|
||||||
|
|
||||||
# Reception map is handled separately from contest map since the reception map
|
# Reception map is handled separately from contest map since the reception map
|
||||||
# can be outdoors, with its own grassy patches.
|
# can be outdoors, with its own grassy patches.
|
||||||
def pbSetReception(*arg)
|
def pbSetReception(*maps)
|
||||||
@reception = []
|
@reception = maps
|
||||||
arg.each do |i|
|
|
||||||
@reception.push(i)
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def pbOffLimits?(map)
|
def pbOffLimits?(map)
|
||||||
# p [map,@contestMap,@reception]
|
return false if @contestMaps.include?(map)
|
||||||
return false if map == @contestMap
|
return false if @reception.include?(map)
|
||||||
@reception.each do |i|
|
|
||||||
return false if map == i
|
|
||||||
end
|
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -90,26 +89,26 @@ class BugContestState
|
|||||||
@start = [startMap, startX, startY, dir]
|
@start = [startMap, startX, startY, dir]
|
||||||
end
|
end
|
||||||
|
|
||||||
def pbSetContestMap(map)
|
|
||||||
@contestMap = map
|
|
||||||
end
|
|
||||||
|
|
||||||
def pbJudge
|
def pbJudge
|
||||||
judgearray = []
|
judgearray = []
|
||||||
if @lastPokemon
|
if @lastPokemon
|
||||||
judgearray.push([-1, @lastPokemon.species, pbBugContestScore(@lastPokemon)])
|
judgearray.push([-1, @lastPokemon.species, pbBugContestScore(@lastPokemon)])
|
||||||
end
|
end
|
||||||
enctype = :BugContest
|
maps_with_encounters = []
|
||||||
if !$PokemonEncounters.map_has_encounter_type?(@contestMap, enctype)
|
@contestMaps.each do |map|
|
||||||
enctype = :Land
|
enc_type = :BugContest
|
||||||
end
|
enc_type = :Land if !$PokemonEncounters.map_has_encounter_type?(@contestMaps, enc_type)
|
||||||
@contestants.each do |cont|
|
if $PokemonEncounters.map_has_encounter_type?(@contestMaps, enc_type)
|
||||||
enc = $PokemonEncounters.choose_wild_pokemon_for_map(@contestMap, enctype)
|
maps_with_encounters.push([map, enc_type])
|
||||||
if !enc
|
|
||||||
raise _INTL("No encounters for map {1}, so can't judge contest", @contestMap)
|
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
raise _INTL("There are no Bug Contest/Land encounters for any Bug Contest maps.") if maps_with_encounters.empty?
|
||||||
|
@contestants.each do |cont|
|
||||||
|
enc_data = maps_with_encounters.sample
|
||||||
|
enc = $PokemonEncounters.choose_wild_pokemon_for_map(enc_data[0], enc_data[1])
|
||||||
|
raise _INTL("No encounters for map {1} somehow, so can't judge contest.", enc_data[0]) if !enc
|
||||||
pokemon = Pokemon.new(enc[0], enc[1])
|
pokemon = Pokemon.new(enc[0], enc[1])
|
||||||
pokemon.hp = rand(1..pokemon.totalhp - 1)
|
pokemon.hp = rand(1...pokemon.totalhp)
|
||||||
score = pbBugContestScore(pokemon)
|
score = pbBugContestScore(pokemon)
|
||||||
judgearray.push([cont, pokemon.species, score])
|
judgearray.push([cont, pokemon.species, score])
|
||||||
end
|
end
|
||||||
@@ -142,7 +141,7 @@ class BugContestState
|
|||||||
pbJudge
|
pbJudge
|
||||||
if $scene.is_a?(Scene_Map)
|
if $scene.is_a?(Scene_Map)
|
||||||
pbFadeOutIn {
|
pbFadeOutIn {
|
||||||
$game_temp.player_transferring = true
|
$game_temp.player_transferring = true
|
||||||
$game_temp.player_new_map_id = @start[0]
|
$game_temp.player_new_map_id = @start[0]
|
||||||
$game_temp.player_new_x = @start[1]
|
$game_temp.player_new_x = @start[1]
|
||||||
$game_temp.player_new_y = @start[2]
|
$game_temp.player_new_y = @start[2]
|
||||||
@@ -193,24 +192,21 @@ class BugContestState
|
|||||||
|
|
||||||
def pbEnd(interrupted = false)
|
def pbEnd(interrupted = false)
|
||||||
return if !@inProgress
|
return if !@inProgress
|
||||||
@otherparty.each do |poke|
|
@otherparty.each { |pkmn| $player.party.push(pkmn) }
|
||||||
$player.party.push(poke)
|
|
||||||
end
|
|
||||||
if interrupted
|
if interrupted
|
||||||
@ended = false
|
@ended = false
|
||||||
else
|
else
|
||||||
if @lastPokemon
|
pbNicknameAndStore(@lastPokemon) if @lastPokemon
|
||||||
pbNicknameAndStore(@lastPokemon)
|
|
||||||
end
|
|
||||||
@ended = true
|
@ended = true
|
||||||
end
|
end
|
||||||
$stats.bug_contest_wins += 1 if place == 0
|
$stats.bug_contest_wins += 1 if place == 0
|
||||||
@lastPokemon = nil
|
|
||||||
@otherparty = []
|
|
||||||
@reception = []
|
|
||||||
@ballcount = 0
|
@ballcount = 0
|
||||||
@inProgress = false
|
@inProgress = false
|
||||||
@decision = 0
|
@decision = 0
|
||||||
|
@lastPokemon = nil
|
||||||
|
@otherparty = []
|
||||||
|
@contestMaps = []
|
||||||
|
@reception = []
|
||||||
timenow = pbGetTimeNow
|
timenow = pbGetTimeNow
|
||||||
@lastContest = timenow.to_i
|
@lastContest = timenow.to_i
|
||||||
$game_map.need_refresh = true
|
$game_map.need_refresh = true
|
||||||
|
|||||||
Reference in New Issue
Block a user