Created
September 4, 2016 19:23
-
-
Save Nikitaw99/b86dfed0b40c8d180459a157e2285aac to your computer and use it in GitHub Desktop.
Simple Fire Emblem battle simulator.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
math.randomseed(os.time()) | |
print("Enter attacker skill stat:") | |
skill = io.read('*n') | |
while skill > 100 or skill < 0 do | |
print("This number is invalid.") | |
print("The number must be between 0 and 100.") | |
print("Enter attacker skill stat:") | |
skill = io.read('*n') | |
end | |
print("Enter defender dodge stat:") | |
dodge = io.read('*n') | |
while dodge > 100 or dodge < 0 do | |
print("This number is invalid.") | |
print("The number must be between 0 and 100.") | |
print("Enter defender dodge stat:") | |
dodge = io.read('*n') | |
end | |
if skill > dodge then | |
do | |
local targetValue = skill - dodge | |
local randomValue = math.random(100) | |
print("Chance to hit: " .. targetValue .. "%.") | |
print("RNG Returned: " .. randomValue .. ".") | |
if targetValue >= randomValue then | |
print("Attacker succesfully hits!") | |
else | |
print("Attacker misses!") | |
end | |
end | |
else | |
print("Defender sucesfully dodges!") | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment