07-01-2003, 11:27 AM
Right... I got carried away and made one. It may be a little long, and there is a bug if you play 16 player and individually do every game with him, but other than that I think it's bug free. Tell me what you all think!
I also think it gets harder the higher your player number, but I didn't have time for a complete desk check to prove it.
It may pull a funny line wrap (probably will), so expect a few errors, just correct those with your delete button. Cut&paste into notepad and enjoy!
Code:
' ----- Sports Sim -----
' Oracle
' webmaster@qbnz.com
OPTION BASE 1
DIM numofpl AS INTEGER, skip(17) AS INTEGER
CLS
INPUT "Number of players? ", numofpl
IF numofpl > 16 THEN numofpl = 16
IF numofpl < 0 THEN numofpl = 0
CLS
DIM names(17) AS STRING, team(17) AS STRING, skpts(17) AS INTEGER, wins(17) AS INTEGER
DIM draws(17) AS INTEGER, losses(17) AS INTEGER, points(17) AS INTEGER, money(17) AS INTEGER
' Get player names
FOR i = 1 TO numofpl
PRINT "What is player"; i; "'s name?"
LOCATE i, 28
INPUT "", names(i)
IF names(i) = "" THEN names(i) = "Player" + STR$(i)
NEXT i
FOR i = 1 TO numofpl
CLS
money(i) = 5000
PRINT "What is "; names(i); "'s team?"
LOCATE 1, 18 + LEN(names(i))
INPUT "", team(i)
IF team(i) = "" THEN team(i) = "Team" + STR$(i)
RANDOMIZE TIMER
skpts(i) = 120 * (.5 + RND)
PRINT names(i); "'s team has"; skpts(i); "skill points."
WHILE INKEY$ = "": WEND
NEXT i
' Get computer player's data
CLS
FOR i = numofpl + 1 TO 16
money(i) = 5000
RANDOMIZE TIMER
skpts(i) = 160 * (.5 + RND)
READ n$
names(i) = n$
READ n$
team(i) = n$
LOCATE i - numofpl
IF i < 16 THEN COLOR i ELSE COLOR 15
PRINT team(i); " has"; skpts(i); "skill points."
NEXT i
WHILE INKEY$ <> "": WEND
WHILE INKEY$ = "": WEND
CLS
COLOR 7
' Calculate wins etc
FOR team1 = 1 TO 16
FOR team2 = 1 TO 16
IF team1 = team2 THEN team2 = team2 + 1
IF team1 <= numofpl AND NOT (skip(team1)) AND team2 <> 16 THEN
DO
CLS
PRINT team(team1); " are up for round"; team1; ", game"; team2
PRINT team(team1); " have"; money(team1); "in the bank."
PRINT "What do you want to do?"
PRINT "(L)ight Training ($250)"
PRINT "(F)ull Training ($400)"
PRINT "(B)uy Skill Point ($150)"
PRINT "(P)urchase Star Player ($1500)"
PRINT "(G)amble ($100)"
PRINT "(S)kip to next player"
PRINT "(N)othing"
PRINT
INPUT "What is your choice? ", choice$
choice$ = LCASE$(LEFT$(choice$, 1))
PRINT "Your skill points were "; skpts(team1)
IF choice$ = "l" THEN
IF money(team1) >= 250 THEN
skpts(team1) = skpts(team1) + CINT(RND * 2)
money(team1) = money(team1) - 250
ELSE GOSUB notrich
END IF
ELSEIF choice$ = "f" THEN
IF money(team1) >= 400 THEN
skpts(team1) = skpts(team1) + CINT(RND * 4)
money(team1) = money(team1) - 400
ELSE GOSUB notrich
END IF
ELSEIF choice$ = "b" THEN
IF money(team1) >= 150 THEN
skpts(team1) = skpts(team1) + 1
money(team1) = money(team1) - 150
ELSE GOSUB notrich
END IF
ELSEIF choice$ = "p" THEN
IF money(team1) >= 1500 THEN
skpts(team1) = skpts(team1) + CINT(RND * 6) + 8
money(team1) = money(team1) - 1500
ELSE GOSUB notrich
END IF
ELSEIF choice$ = "g" THEN
IF money(team1) >= 100 THEN
skpts(team1) = (skpts(team1) * (.9 + (RND / 5)))
money(team1) = money(team1) - 100
ELSE GOSUB notrich
END IF
ELSEIF choice$ = "s" THEN skip(team1) = -1
END IF
PRINT "Your skill points now are "; skpts(team1)
WHILE INKEY$ <> "": WEND
WHILE INKEY$ = "": WEND
LOOP UNTIL choice$ = "n" OR choice$ = "" OR choice$ = "s"
ELSE
skpts(team1) = skpts(team1) + INT(RND * 2) + 2
END IF
CLS
RANDOMIZE TIMER
t1 = skpts(team1) * (.75 + (RND / 2))
t2 = skpts(team2) * (.75 + (RND / 2))
IF team1 <= numofpl AND NOT (skip(team1)) THEN
PRINT "The Match"
PRINT team(team1); " vs "; team(team2)
SLEEP 3.5
END IF
IF t1 > t2 + 8 + team2 THEN ' Who is the winner? Change the +8 to
wins(team1) = wins(team1) + 1 ' alter the chance of a draw
losses(team2) = losses(team2) + 1
money(team1) = money(team1) + 400
IF team1 <= numofpl AND NOT (skip(team1)) THEN
PRINT "Congratulations, you won!"
PRINT "You gain 3 points and $400"
WHILE INKEY$ <> "": WEND
WHILE INKEY$ = "": WEND
END IF
ELSEIF t2 + team2 > t1 + 8 THEN
wins(team2) = wins(team2) + 1
losses(team1) = losses(team1) + 1
money(team1) = money(team1) - 100
IF team1 <= numofpl AND NOT (skip(team1)) THEN
PRINT "Awwww... you lost!"
PRINT "You'll have to do better next time..."
WHILE INKEY$ <> "": WEND
WHILE INKEY$ = "": WEND
END IF
ELSE
draws(team1) = draws(team1) + 1
draws(team2) = draws(team2) + 1
money(team1) = money(team1) + 150
IF team1 <= numofpl AND NOT (skip(team1)) THEN
PRINT "Well done, a draw. You could've won though..."
PRINT "You gain 1 point and $150"
WHILE INKEY$ <> "": WEND
WHILE INKEY$ = "": WEND
END IF
END IF
NEXT team2
NEXT team1
' Work out the points for each team
FOR t = 1 TO 16
points(t) = wins(t) * 3 + draws(t)
NEXT t
' Sorting the results
FOR u = 1 TO 16
FOR r = 1 TO 16
IF points(r) < points(r + 1) THEN
SWAP points(r), points(r + 1)
SWAP wins(r), wins(r + 1)
SWAP draws(r), draws(r + 1)
SWAP losses(r), losses(r + 1)
SWAP skpts(r), skpts(r + 1)
SWAP team(r), team(r + 1)
SWAP names(r), names(r + 1)
SWAP money(r), money(r + 1)
IF r > 1 THEN r = r - 1 ELSE r = 1
END IF
NEXT r
NEXT u
' Results
CLS
COLOR 3
PRINT SPACE$(31) + "** League Table **"
LOCATE 2, 5
PRINT STRING$(70, "-")
PRINT " Team Wins Draws Losses Points SK.Pts Name"
PRINT " " + STRING$(70, "-")
COLOR 2
FOR y = 1 TO 16
LOCATE y + 4 + yinc, 5
PRINT team(y)
LOCATE y + 4 + yinc, 23
PRINT wins(y)
LOCATE y + 4 + yinc, 30
PRINT draws(y)
LOCATE y + 4 + yinc, 38
PRINT losses(y)
LOCATE y + 4 + yinc, 45
PRINT points(y)
LOCATE y + 4 + yinc, 52
PRINT skpts(y)
LOCATE y + 4 + yinc, 60
PRINT names(y)
IF y = 4 OR y = 12 THEN
LOCATE y + 5 + yinc, 5
COLOR 3
PRINT STRING$(70, "-")
yinc = yinc + 1
IF y = 4 THEN COLOR 6 ELSE COLOR 4
END IF
NEXT y
WHILE INKEY$ <> "": WEND
WHILE INKEY$ = "": WEND
CLS
PRINT "SOCCER.BAS by Oracle for the QBNews 1 hour game challenge"
PRINT "All opinions either to the QBNews challenge forum or webmaster@qbnz.com"
PRINT "I'm stuffed... I'm gonna watch TV now ;)"
END
notrich:
COLOR 4
PRINT "ERROR! You can't afford that!"
WHILE INKEY$ = "": WEND
COLOR 7
RETURN
DATA "Joe Smith","Manchester United"
DATA "Bobby Kane","Liverpool"
DATA "James Underhill","Chelsea"
DATA "Simon Giles","Spurs"
DATA "Tom Bates","Brighton"
DATA "Mr Smith","Agents"
DATA "Morpheus","Xions"
DATA "Luke Skywalker","Rebellians"
DATA "Darth Vader","Empireans"
DATA "Linus Torvalds","Linuxians"
DATA "Bill Gates","Microsoftians"
DATA "Soo Nee","Plastationites"
DATA "Nintendo","Gameboyites"
DATA "Tiger Woods","Golfians"
DATA "Serena Williams","Screamers"
DATA "Paul Gasgoine","Druggies"
I also think it gets harder the higher your player number, but I didn't have time for a complete desk check to prove it.
It may pull a funny line wrap (probably will), so expect a few errors, just correct those with your delete button. Cut&paste into notepad and enjoy!