Leagues

From WikiManual
Revision as of 18:46, 24 December 2006 by Griz (talk | contribs)
Jump to: navigation, search

Code/Debugging/Fixes/Changes for Leagues



Holy crap!!!
League code is all over the place!
Will just keep stashing it here as i find it.
General 
Declarations

Public Type datispecie
  Skin(13) As Integer
  path As String
  Name As String
  Stnrg As Integer
  Veg As Boolean
  Fixed As Boolean
  color As Long
  Colind As Integer
  Postp As Single
  Poslf As Single
  Posdn As Single
  Posrg As Single
  qty As Integer
  Comment As String
  Leaguefilecomment As String
  Mutables As mutationprobs
  CantSee As Boolean                ' Flag indicating eyes should be turned off for this 

species
  DisableDNA As Boolean             ' Flag indicating DNA should not execute for 

this species
  DisableMovementSysvars As Boolean ' Flag indicating movement sysvars 

should be disabled for this species
  CantReproduce As Boolean          ' Flag indicating whether reproduction has 

been disabled for this species.
End Type
General
Declarations

'For League mode: (runs a series of F1 contests, 1 on 1)
Public LeagueMode As Boolean
Public Leaguename As String
Public Leaguererun As Boolean
Public LeagueEntrants(30) As datispecie 'all those already in the league
Public numLeagueEntrants As Integer
Public LeagueChallengers(31) As datispecie 'all those challenging (31 instead of 

30 for some loop functions)
Public Defender As Integer 'couple used to determine which bots are facing 

which in League mode
Public Attacker As Integer
Private eye11 As Integer 'for eye fudging.  Search 'fudge' to see what I mean
General
Startsim

If LeagueMode Then
    LeagueForm.Show
    SimOpts.TotRunCycle = -1
  End If
General
StartSimul

'Restart
  'Leaguemode handles restarts differently so only restart here if not in 

leaguemode
  If totnvegs = 0 And RestartMode And Not LeagueMode Then
  ' totnvegs = 1
  ' Contests = Contests + 1
    ReStarts = ReStarts + 1
  ' Form1.StartSimul
    StartAnotherRound = True
  End If
End Sub
General
FindSpecies

  If TotSpecies = 1 Then
'    If Not LeagueMode Then
      ContestMode = False
      MDIForm1.F1Piccy.Visible = False
      Contest_Form.Visible = False
      t = MsgBox("You have only selected one species for combat. Formula 1 

mode disabled", vbOKOnly)
      Exit Sub
 '   End If
  End If

MDIForm1 (Code)

Private Sub Leagues_Click()
 optionsform.SSTab1.Tab = 4
  NetEvent.Timer1.Enabled = False
  NetEvent.Hide
  optionsform.Show vbModal
End Sub
RerunCheck

Private Sub RerunCheck_Click()
  Leaguererun = CBool(RerunCheck.value)
End Sub

LeagueCheck

Private Sub LeagueCheck_Click()
  If LeagueCheck.value = 1 Then
    If F1Check.value <> 1 Then
      F1Check.value = 1
      F1check_Click
    End If
    LeagueMode = True
    TmpOpts.League = True
    
    If Leaguetype(0).value = False Then
      Leaguetype(0).value = True
    End If
  
  Else
    TmpOpts.League = False
    LeagueMode = False
    'Leaguetype(0).value = False
  End If
End Sub

Private Sub LeagueAutoCheck()
  If LeagueCheck.value <> 1 Then
    LeagueCheck.value = 1
    LeagueCheck_Click
  End If
End Sub

Private Sub LeagueF1Option_Click()
  Leaguename.text = "F1"
  LeagueAutoCheck
End Sub

Private Sub LeagueF2Option_Click()
  Leaguename.text = "F2"
  LeagueAutoCheck
End Sub

Private Sub LeageSBOption_Click()
  Leaguename.text = "Shortbot"
  LeagueAutoCheck
End Sub

Private Sub LeagueMBOption_Click()
  Leaguename.text = "Multibot"
  LeagueAutoCheck
End Sub

Private Sub Leaguetype_Click(Index As Integer)
  'If Leaguetype(Index).value = False Then
  ''  Leaguetype(Index).value = True
  'End If
End Sub

Private Sub LightText_lostfocus()
  Dim a As Single
  a = val(LightText.text)
  If a < LightUpDn.Min Then a = LightUpDn.Min
  If a > LightUpDn.Max Then a = LightUpDn.Max
  LightUpDn.value = a
  TmpOpts.LightIntensity = a
End Sub

StartNew

If LeagueMode = True Then LeagueForm.Visible = True ' EricL 3/20/2006 Have 

to bring up league form after Options dialog goes away
  
  'Form1.Active = True
  
    'this just tricks the program into thinking we have enough
  'species for F1 mode.
  'If TmpOpts.League = True And TmpOpts.SpeciesNum = 2 Then
  '  additem TmpOpts.Specie(1).Name
  '  TmpOpts.SpeciesNum = TmpOpts.SpeciesNum + 1
  'End If
  
  SimOpts = TmpOpts
  
  If SimOpts.League = True Then
    LeagueMode = True 'should be anyway, but sometimes when
                      'restarting a league it screws up
    LeagueInputChallengers
    SetupLeague_Options
  '  SimOpts.F1 = True
    LeagueForm.F1ChallengeOption_Click
  End If
  
  
  If Form1.Active Then Form1.SecTimer.Enabled = True
  
  
  StartAnotherRound = True ' Set true for first simulation.  Will get set true if 

running leagues or using auto-restart mode
  While StartAnotherRound
    StartAnotherRound = False
    Form1.StartSimul
  Wend
End Sub