Football game

Hi everybody this is my soccer simulator game. I decided to try to make it using tests and only two functions.

@LiamP where?xp

@stevon8ter Wait for it… I’m constantly reloading the page. :))

--# Main
function setup()
print("You Play For Your Dream Team")
print("Your Player Is Great!")
print("Press 'Restart'")
print("")
    a = math.random(1,12)
    b = math.random(1,12)
    c = math.random(1,12)
    d = math.random(1,12)
    e = math.random(1,12)
    f = math.random(1,12)
    g = math.random(1,12)
    h = math.random(1,12)
    i = math.random(1,12)
    j = math.random(1,12)
    k = math.random(1,12)
    l = math.random(1,12)
    m = math.random(1,14)
    n = math.random(1,12)
    if a > b and a > c and a > d and a > e and a > f and a > g and a > h and a > i and a > j and a > k and a > l
    and a > m and a > n
then print("Goal!","Other Team Kick Off")elseif
    b > a and b > c and b > d and b > e and b > f and b > g and b > h and b > i and b > j and b > k and b > l and b > m and b > n 
then print("Pass to Johnson") elseif
    c > a and c > b and c > d and c > e and c > f and c > g and c > h and c > i and
    c > j and c > k and c > l and c > m and c > n
then print(" Pass to Stuart")elseif
    d > a and d > b and d > c and d > e and d > f and d > g and d > h and d > i and d > j and d > k and d > l and c > m and d > n
then print("Pass to Brown")elseif
     e > a and e > b and e > c and e > d and e > f and e > g and e > h and e > i and e > j and e > k and e > l and e > m and e > n
then print("Passed to You")elseif
    f > a and f > b and f > c and f > d and f > e and f > g and f > h and f > i and f > j and f > k and f > l
    and f > m and f > n
then print("Pass to Ambrose")elseif
    g > a and g > b and g > c and g > d and g > e and g > f and g > h and g > i and g > j and g > k and g > l
    and g > m and g > n
then print("Pass to Mulgrew")elseif
    h > a and h > b and h > c and h > d and h > e and h > f and h > g and h > i and h > j and h > k and h > l
    and h > m and h > n
then print("Pass to Matthews")elseif
    i > a and i > b and i > c and i > d and i > e and i > f and i > g and i > h and i > j and i > k and i > l
    and i > m and i > n
then print("Pass to Balde")elseif
    j > a and j > b and j > c and j > d and j > e and j > f and j > g and j > h and j > i and j > k and j > l
    and j > m and j > n
then print("Pass to Vigurs")elseif
     k > a and k > b and k > c and k > d and k > e and k > f and k > g and k > h and k > i and k > j and k > l
    and k > m and k > n
then print("Pass to Hooper")elseif
    l > a and l > b and l > c and l > d and l > e and l > f and l > g and l > h and l > i and l > j and l > k
    and l > m and l > n
then print("Pass to Muir")elseif
    m > a and m > b and m > c and m > d and m > e and m > f and m > g and m > h and m > i and m > j and m > k
    and m > l and m > n
then print("Other Team Possession")elseif
    n > a and n > b and n > c and n > d and n > e and n > f and n > g and n > h and n > i and n > j and n > k
     and n > l and n > m
then print("Other Team Goal!","Your Kick Off")else
    print("Team Playing Well")end
end

function draw()
        background(28, 138, 30, 255)
    sprite("Documents:Football",374,374)
end

@SkyTheCoder hahaha you’re silly xD it might take another day or so, or maybe a minute, maybe even a week… so much luck holding on to it hahaha xd

edit! there it is

@LiamP best is to putt ~~~ in front and behind your code, it will format everything nicely, and is that how you code, or do you use indents ?

Sorry I’ve not used this before, how do you put the code into a bubble?

@LiamP use ~~~ in front and behind the code

I just did it when I was bored

I just did it when I was bored

i like, very original
but random(1,12) can change with elapsed time and tiredness

you can see pushball in the forum

perhaps clear the long lines with > (replaced by (test(i) )
and use an array

tab = { }
for i=1 to 14 do tab[i]=math.random(1,12) end
tab(13)]=math.random(1,14)

function test(i)
  ok=1
  for j=1 to 12 do
    if j==i then
      -- not test need
    else
       ok = ok and ( i>j )
    end
  end
return ok
end

i have not tested

I could also have done this-

function setup()
    print("You Manage Your Dream Team")
    print("Press 'Restart'")
    print("")
    z = math.random(1,12)
    a = math.random(1,12)
    b = math.random(1,12)
    c = math.random(1,12)
    d = math.random(1,12)
    e = math.random(1,12)
    f = math.random(1,12)
    g = math.random(1,12)
    h = math.random(1,12)
    i = math.random(1,12)
    j = math.random(1,12)
    k = math.random(1,12)
    l = math.random(1,12)
    m = math.random(1,12)
    n = math.random(1,12)
    
    if a==z then print("Pass to Muir")elseif
        b==z then print("Pass to Johnson")elseif
            c==z then print("Pass to Stuart")elseif
                d==z then print("Pass to Stokes")elseif
                    e==z then print("Pass to Hooper")elseif
                        f==z then print("Pass to Ambrose")elseif
                            g==z then print("Pass to Muir")elseif
                                h==z then print("Pass to Scott")elseif
                                    i==z then print("Pass to Wilson")elseif
                                        j==z then print("Pass to Eminike")elseif
                                            k==z then print("Pass to Lukaku")elseif
                                                l==z then print("Goal! Other Team Kick Off")elseif
                                                    m==z then print("Other Team Possession")elseif
                                                        n==z then print("Other Team Goal! Your Kick Off")else
                                                            print("Playing Well")end
                                                            
end

function draw()
    background(70, 174, 43, 255)
    sprite("Documents:Football",374,374)
    end
function setup()
    print("You Manage Your Dream Team")
    print("Press 'Restart'")
    print("")
    z = math.random(1,12)
    a = math.random(1,12)
    b = math.random(1,12)
    c = math.random(1,12)
    d = math.random(1,12)
    e = math.random(1,12)
    f = math.random(1,12)
    g = math.random(1,12)
    h = math.random(1,12)
    i = math.random(1,12)
    j = math.random(1,12)
    k = math.random(1,12)
    l = math.random(1,12)
    m = math.random(1,12)
    n = math.random(1,12)
    
    if a==z then print("Pass to Muir")elseif
        b==z then print("Pass to Johnson")elseif
            c==z then print("Pass to Stuart")elseif
                d==z then print("Pass to Stokes")elseif
                    e==z then print("Pass to Hooper")elseif
                        f==z then print("Pass to Ambrose")elseif
                            g==z then print("Pass to Muir")elseif
                                h==z then print("Pass to Scott")elseif
                                    i==z then print("Pass to Wilson")elseif
                                        j==z then print("Pass to Eminike")elseif
                                            k==z then print("Pass to Lukaku")elseif
                                                l==z then print("Goal! Other Team Kick Off")elseif
                                                    m==z then print("Other Team Possession")elseif
                                                        n==z then print("Other Team Goal! Your Kick Off")else
                                                            print("Playing Well")end
                                                            
end

function draw()
    background(70, 174, 43, 255)
    sprite("Documents:Football",374,374)
    end

@LiamP

Here is a tip, at the top of your post there is an edit button :wink:

@LiamP Interesting game. Here is your original code using a table and a “for loop”.


--# Main
function setup()
    play={}
    table.insert(play,"Goal!, Other Team Kick Off")
    table.insert(play,"Pass to Johnson")
    table.insert(play,"Pass to Stuart")
    table.insert(play,"Pass to Brown")
    table.insert(play,"Passed to You")
    table.insert(play,"Pass to Ambrose")
    table.insert(play,"Pass to Mulgrew")
    table.insert(play,"Pass to Matthews")
    table.insert(play,"Pass to Balde")
    table.insert(play,"Pass to Vigurs")
    table.insert(play,"Pass to Hooper")
    table.insert(play,"Pass to Muir")
    table.insert(play,"Other Team Possession")
    table.insert(play,"Other Team Goal!, Your Kick Off")
    table.insert(play,"Team Playing Well")

    max,eq=0,0
    for z=1,14 do
        r=math.random(1,12)
        if r==max then
            eq=1
        elseif r>max then
            max=r
            result=z
            eq=0
        end        
    end
    if eq==1 then
        result=15
    end
    print("You Play For Your Dream Team")
    print("Your Player Is Great!")
    print("Press 'Restart'")
    print("")
    print(play[result])
end

function draw()
        background(28, 138, 30, 255)
        sprite("Planet Cute:Character Boy",374,374)
end

@LiamP - there is a much better way to write the code

First put all the names into a table,eg

players={"Muir","Johnson",....}

And your random numbers in another table

rand={}
for i=1,14 do  rand[i]=math.random(1,12) end
z=math.random(1,12) 

Then your test becomes very simple, like so

matchFound=false
for i=1,11 do
    if rand[i]==z then print("Pass to"..players[i]) matchFound=true break end
end
if matchFound==false then
  if rand[12]==z then print("Goal. other team kick off")
  --do same for 13 and 14   
end

Thanks @Ignatz thats really helpful:)