mirror of
https://gitlab.com/Deukhoofd/BattleSim.git
synced 2025-10-27 18:00:03 +00:00
Added Smogon tiering system, made team invisible clause, sorted all pokemon
This commit is contained in:
@@ -1,7 +1,9 @@
|
||||
{_} = require('underscore')
|
||||
{Conditions} = require('../shared/conditions')
|
||||
{Tiers} = require('../shared/tier')
|
||||
{Protocol} = require('../shared/protocol')
|
||||
pbv = require('../shared/pokebattle_values')
|
||||
tiering = require('../shared/tier')
|
||||
gen = require('./generations')
|
||||
alts = require('./alts')
|
||||
|
||||
@@ -75,6 +77,21 @@ createPBVCondition = (totalPBV) ->
|
||||
createPBVCondition(1000)
|
||||
createPBVCondition(500)
|
||||
|
||||
createTierCondition = (conditionName, tier) ->
|
||||
createCondition Conditions[conditionName],
|
||||
validateTeam: (team, genData) ->
|
||||
errors = []
|
||||
tierdata = Tiers[tier]
|
||||
teamtier = tiering.determineTier(genData, team)
|
||||
if teamtier.tierRank > tierdata.tierRank
|
||||
errors.push "Your team tier may not exceed the #{tierdata.humanName} tier"
|
||||
if team.length != 6
|
||||
errors.push "Your team must have 6 pokemon."
|
||||
return errors
|
||||
|
||||
for key, val of Tiers
|
||||
createTierCondition("TIER_#{key}", key)
|
||||
|
||||
createCondition Conditions.SLEEP_CLAUSE,
|
||||
attach:
|
||||
initialize: ->
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -10,6 +10,7 @@ gen = require './generations'
|
||||
auth = require('./auth')
|
||||
learnsets = require '../shared/learnsets'
|
||||
{Conditions, SelectableConditions, Formats, DEFAULT_FORMAT} = require '../shared/conditions'
|
||||
ConditionsFunc = require '../shared/conditions'
|
||||
pbv = require '../shared/pokebattle_values'
|
||||
config = require './config'
|
||||
errors = require '../shared/errors'
|
||||
@@ -34,7 +35,8 @@ MAX_NICKNAME_LENGTH = 15
|
||||
class @BattleServer
|
||||
constructor: ->
|
||||
@queues = {}
|
||||
for format of Formats
|
||||
allformats = ConditionsFunc.Formats()
|
||||
for format of allformats
|
||||
@queues[format] = new BattleQueue()
|
||||
@battles = {}
|
||||
|
||||
@@ -221,7 +223,8 @@ class @BattleServer
|
||||
return true
|
||||
|
||||
beginBattles: (next) ->
|
||||
array = for format in Object.keys(Formats)
|
||||
allformats = ConditionsFunc.Formats()
|
||||
array = for format in Object.keys(allformats)
|
||||
do (format) => (callback) =>
|
||||
@queues[format].pairPlayers (err, pairs) =>
|
||||
if err then return callback(err)
|
||||
@@ -239,7 +242,8 @@ class @BattleServer
|
||||
|
||||
# Creates a battle and returns its battleId
|
||||
createBattle: (rawFormat = DEFAULT_FORMAT, pair = [], conditions = []) ->
|
||||
format = Formats[rawFormat]
|
||||
allformats = ConditionsFunc.Formats()
|
||||
format = allformats[rawFormat]
|
||||
generation = format.generation
|
||||
conditions = conditions.concat(format.conditions)
|
||||
{Battle} = require("../server/#{generation}/battle")
|
||||
@@ -369,8 +373,10 @@ class @BattleServer
|
||||
# Returns an empty array if the given team is valid, an array of errors
|
||||
# otherwise.
|
||||
validateTeam: (team, format = DEFAULT_FORMAT, conditions = []) ->
|
||||
return [ "Invalid format: #{format}." ] if format not of Formats
|
||||
format = Formats[format]
|
||||
allformats = ConditionsFunc.Formats()
|
||||
return [ "Invalid format: #{format}." ] if format not of allformats
|
||||
allformats = ConditionsFunc.Formats()
|
||||
format = allformats[format]
|
||||
return [ "Invalid team format." ] if team not instanceof Array
|
||||
return [ "Team must have 1 to 6 Pokemon." ] unless 1 <= team.length <= 6
|
||||
conditions = conditions.concat(format.conditions)
|
||||
|
||||
Reference in New Issue
Block a user