jeudi 17 mai 2018

Why does my division operator keep returning a zero?

When I print the result of "chances" it keeps returning a value of "0". I am not sure if it has to do with me using the rand operator. How can I fix this so it will return its actual value instead of 0?

    p1Health = rand(50..100).to_i
    p1Attack = rand(25..50).to_i
    p1Overall = (p1Health + p1Attack).to_i

    p2Health = rand(50..100).to_i
    p2Attack = rand(25..50).to_i
    p2Overall = (p2Health + p2Attack).to_i

    p1p2 = p1Overall + p2Overall

    chances = p1Overall / (p1Overall + p2Overall)




Aucun commentaire:

Enregistrer un commentaire