Skip to content
This repository has been archived by the owner on May 11, 2020. It is now read-only.

Commit

Permalink
Merge pull request #26 from kaborja/patch-1
Browse files Browse the repository at this point in the history
Update game.lua
  • Loading branch information
Seniru committed Sep 20, 2019
2 parents 4034a9a + 2f4b64c commit 66b7922
Showing 1 changed file with 28 additions and 18 deletions.
46 changes: 28 additions & 18 deletions game.lua
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ function Player.new(name)
self.job = "Cheese collector"
self.ownedCompanies = {}
self.boss = "shaman"
self.company = "Atelie801"
self.company = "Atelier801"
self.inventory = {}
ui.addTextArea(1000, "", name, CONSTANTS.BAR_X, 340, CONSTANTS.BAR_WIDTH, 20, 0xff0000, 0xee0000, 1, true)
ui.addTextArea(2000, "", name, CONSTANTS.BAR_X, 370, 1, 17, 0x00ff00, 0x00ee00, 1, true)
Expand Down Expand Up @@ -138,7 +138,7 @@ function Player:setCourse(course)
self.learnProgress = 0
self.eduLvl = course.level
self.eduStream = course.stream
ui.addTextArea(3000, "Lessons left: 0/" .. find(self.learning, courses).lessons, self.name, 5, 100, 50, 50, nil, nil, 0.8, false)
ui.addTextArea(3000, "Lessons left:\n0/" .. find(self.learning, courses).lessons, self.name, 5, 100, 50, 50, nil, nil, 0.8, false)
end

function Player:setJob(job)
Expand Down Expand Up @@ -172,7 +172,7 @@ function Player:learn()

if self.money > find(self.learning, courses).feePerLesson then
self.learnProgress = self.learnProgress + 1
ui.updateTextArea(3000, "Lessons left:" .. self.learnProgress .. "/" .. find(self.learning, courses).lessons, self.name)
ui.updateTextArea(3000, "Lessons left:\n" .. self.learnProgress .. "/" .. find(self.learning, courses).lessons, self.name)
self:setMoney(-find(self.learning, courses).feePerLesson, true)
if self.learnProgress >= find(self.learning, courses).lessons then
self:addDegree(self.learning)
Expand Down Expand Up @@ -202,7 +202,7 @@ function Player:useMed(med)
end

function Player:updateStatsBar()
ui.updateTextArea(10, "<p align='right'>Money: $" .. self.money .." </p> ", self.name)
ui.updateTextArea(10, "<p align='right'>Money: $" .. formatNumber(self.money) .." </p> ", self.name)
ui.updateTextArea(11, " Level: " .. self.level, self.name)
ui.updateTextArea(1, "<br><p align='center'><b>" .. self.name .. "</b></p>", self.name)
end
Expand Down Expand Up @@ -379,6 +379,7 @@ function displayTips(target)
end

function displayProfile(name, target)
name = upper(name)
local p = players[name] or players[name .. "#0000"]
if p then
ui.addTextArea(900, closeButton .. "<p align='center'><font size='15'><b><BV>" .. p:getName() .."</BV></b></font></p><br><b>Level:</b> " .. tostring(p:getLevel()) .. "<BL><font size='12'> [" .. tostring(p:getXP()) .. "XP / " .. tostring(calculateXP(p:getLevel() + 1)) .. "XP]</font></BL><br><b>Money:</b> $" .. formatNumber(p:getMoney()) .. "<br><br><b>Working as a</b> " .. p:getJob() , target, 300, 100, 200, 130, nil, nil, 1, true)
Expand Down Expand Up @@ -459,17 +460,26 @@ function table.tostring(tbl)
return s .. "]"
end

function float(n, digits)
digits = digits or 1
return math.ceil(n * 10^digits) / 10^digits
end

function formatNumber(n)
if n >= 1000000000000 then
return math.floor(n / 100000000000) .. "T"
return float(math.floor(n / 100000000000),1) .. "T"
elseif n >= 1000000000 then
return math.floor(n / 100000000) .. "B"
return float(math.floor(n / 100000000),1) .. "B"
elseif n >= 1000000 then
return math.floor(n / 100000) .. "M"
return float(math.floor(n / 100000),1) .. "M"
elseif n >= 10000 then
return math.floor(n / 1000) .. "K"
return float(math.floor(n / 1000),1) .. "K"
end
return n
return float(n,1)
end

function upper(str)
return string.upper(string.sub(str,1,1)) .. string.lower(string.sub(str,2))
end

function getTotalPages(type, target)
Expand Down Expand Up @@ -733,7 +743,7 @@ end

--game logic
--creating tips
createTip("You Need $10 To Start A New Company!", 1)
createTip("You Need $5000 To Start A New Company!", 1)
createTip("You Gain Money From Your Workers!", 2)
createTip("Look At The Stats of The Company Before You Apply for it!", 3)
createTip("The Better The Job The Better The Income!", 4)
Expand Down Expand Up @@ -765,7 +775,7 @@ createTip("Click Tips When You Need Help", 29)
createTip("The Health Refreshes Every Moment <3", 30)

players["shaman"] = Player("shaman")
table.insert(companies, Company("Atelie801", "shaman"))
table.insert(companies, Company("Atelier801", "shaman"))

--creating and storing HealthPack tables
table.insert(healthPacks, HealthPack("Cheese", 5, 0.01, true, "Just a cheese! to refresh yourself"))
Expand Down Expand Up @@ -794,14 +804,14 @@ table.insert(courses, Course("Law", 35000, 80, 5, "admin"))
table.insert(courses, Course("Cheese trading-II", 90000, 75, 5, "bs"))
table.insert(courses, Course("Fullstack cheese developing", 40000, 70, 5, "it"))
--creating and stofing Job tables
table.insert(jobs, Job("Cheese collector", 10, 0.05, 1, nil, "shaman", "Atelie801"))
table.insert(jobs, Job("Junior miner", 25, 0.1, 3, nil, "shaman", "Atelie801"))
table.insert(jobs, Job("Cheese producer", 50, 0.15, 7, nil, "shaman", "Atelie801"))
table.insert(jobs, Job("Cheese miner", 250, 0.2, 10, "Cheese mining", "shaman", "Atelie801"))
table.insert(jobs, Job("Cheese collector", 10, 0.05, 1, nil, "shaman", "Atelier801"))
table.insert(jobs, Job("Junior miner", 25, 0.1, 3, nil, "shaman", "Atelier801"))
table.insert(jobs, Job("Cheese producer", 50, 0.15, 7, nil, "shaman", "Atelier801"))
table.insert(jobs, Job("Cheese miner", 250, 0.2, 10, "Cheese mining", "shaman", "Atelier801"))
table.insert(jobs, Job("Cheese trader", 200, 0.2, 12, "Cheese trading", "shaman"))
table.insert(jobs, Job("Cheese developer", 300, 0.3, 12, "Cheese developing", "shaman", "Atelie801"))
table.insert(jobs, Job("Cheese wholesaler", 700, 0.2, 15, "Cheese trading-II", "shaman", "Atelie801"))
table.insert(jobs, Job("Fullstack cheeese developer", 9000, 0.4, 15, "Fullstack cheese developing", "shaman", "Atelie801"))
table.insert(jobs, Job("Cheese developer", 300, 0.3, 12, "Cheese developing", "shaman", "Atelier801"))
table.insert(jobs, Job("Cheese wholesaler", 700, 0.2, 15, "Cheese trading-II", "shaman", "Atelier801"))
table.insert(jobs, Job("Fullstack cheeese developer", 9000, 0.4, 15, "Fullstack cheese developing", "shaman", "Atelier801"))

for name, player in pairs(tfm.get.room.playerList) do
players[name] = Player(name)
Expand Down

0 comments on commit 66b7922

Please sign in to comment.