|
| 1 | +function createTeam(name) |
| 2 | + return { |
| 3 | + name = name, |
| 4 | + drivers = { |
| 5 | + { name = "Driver A", speed = 100, reliability = 90 }, |
| 6 | + { name = "Driver B", speed = 95, reliability = 95 } |
| 7 | + }, |
| 8 | + carPerformance = 100, |
| 9 | + budget = 1000000, |
| 10 | + upgrades = { |
| 11 | + aero = 1, |
| 12 | + engine = 1, |
| 13 | + tires = 1 |
| 14 | + } |
| 15 | + } |
| 16 | +end |
1 | 17 |
|
| 18 | +function upgradeDriver(driverIndex, stat) |
| 19 | + local cost = 100000 |
| 20 | + if playerTeam.budget >= cost then |
| 21 | + if stat == "speed" then |
| 22 | + playerTeam.drivers[driverIndex].speed = playerTeam.drivers[driverIndex].speed + 5 |
| 23 | + elseif stat == "reliability" then |
| 24 | + playerTeam.drivers[driverIndex].reliability = playerTeam.drivers[driverIndex].reliability + 5 |
| 25 | + end |
| 26 | + playerTeam.budget = playerTeam.budget - cost |
| 27 | + end |
| 28 | +end |
| 29 | + |
| 30 | +function upgradeCar(upgradeType) |
| 31 | + local cost = 200000 |
| 32 | + if playerTeam.budget >= cost then |
| 33 | + if upgradeType == "performance" then |
| 34 | + playerTeam.carPerformance = playerTeam.carPerformance + 10 |
| 35 | + end |
| 36 | + -- Można dodać więcej typów ulepszeń |
| 37 | + playerTeam.budget = playerTeam.budget - cost |
| 38 | + end |
| 39 | +end |
| 40 | + |
| 41 | +function generateOpponents(num) |
| 42 | + opponents = {} |
| 43 | + for i = 1, num do |
| 44 | + table.insert(opponents, { |
| 45 | + name = "Team " .. i, |
| 46 | + drivers = { |
| 47 | + { name = "Opp Driver " .. i .. "A", speed = 90 + math.random(20), reliability = 80 + math.random(20) }, |
| 48 | + { name = "Opp Driver " .. i .. "B", speed = 90 + math.random(20), reliability = 80 + math.random(20) } |
| 49 | + }, |
| 50 | + carPerformance = 90 + math.random(20) |
| 51 | + }) |
| 52 | + end |
| 53 | +end |
| 54 | + |
| 55 | +function awardPrizes() |
| 56 | + -- Nagrody na podstawie pozycji |
| 57 | + local playerPositions = {} |
| 58 | + for i, car in ipairs(positions) do |
| 59 | + if car.team == playerTeam.name then |
| 60 | + table.insert(playerPositions, i) |
| 61 | + end |
| 62 | + end |
| 63 | + table.sort(playerPositions) |
| 64 | + local prizes = {500000, 300000, 200000, 100000, 50000} -- Dla top 5 |
| 65 | + for i = 1, math.min(2, #playerPositions) do |
| 66 | + local pos = playerPositions[i] |
| 67 | + if pos <= 5 then |
| 68 | + playerTeam.budget = playerTeam.budget + (prizes[pos] or 0) |
| 69 | + end |
| 70 | + end |
| 71 | +end |
0 commit comments