|
@@ -2,6 +2,7 @@ package main
|
|
|
|
|
|
import (
|
|
|
"log"
|
|
|
+ "math/rand"
|
|
|
"time"
|
|
|
|
|
|
"gorm.io/driver/sqlite"
|
|
@@ -108,11 +109,38 @@ type Ship struct {
|
|
|
ArmorPlates uint64 // Bumps HP up
|
|
|
RepairBays uint64 // Allows you to hold Repair Drones to repair HP in combat
|
|
|
RepairDrones uint64 // Each repair drone can repair 0-1 HP per turn in combat (but if you take damage there is a chance to loose a drone instead)
|
|
|
- ShieldCapacitors uint64 // Bumps SP up, each Capacitor also adds a resistance to the amout of SP regained in combat
|
|
|
+ ShieldCapacitors uint64 // Bumps SP up, each Capacitor also adds a resistance to the amount of SP regained in combat
|
|
|
ShieldGenerators uint64 // Regains SP of 0-1 SP per turn, it is calculated together then applies a resistance rating based on the number of capacitors installed
|
|
|
Engines uint64 // Affects dodge and escape chances, "mass" is the number of installed parts
|
|
|
}
|
|
|
|
|
|
+func (s *Ship) Mass() uint64 {
|
|
|
+ m := uint64(0)
|
|
|
+ m += s.Guns
|
|
|
+ m += s.RocketLaunchers
|
|
|
+ m += (s.ArmorPlates * 2) // Armor is heavy
|
|
|
+ m += s.RepairBays
|
|
|
+ m += s.ShieldCapacitors // Shields are light
|
|
|
+ m -= s.Engines
|
|
|
+ return m
|
|
|
+}
|
|
|
+
|
|
|
+func (s *Ship) FireGuns() uint64 {
|
|
|
+ total := 0
|
|
|
+ for range make([]byte, s.Guns) {
|
|
|
+ total += rand.Intn(3)
|
|
|
+ }
|
|
|
+ return uint64(total)
|
|
|
+}
|
|
|
+
|
|
|
+func (s *Ship) DroneRepair() uint64 {
|
|
|
+ total := 0
|
|
|
+ for range make([]byte, s.RepairDrones) {
|
|
|
+ total += rand.Intn(2)
|
|
|
+ }
|
|
|
+ return uint64(total)
|
|
|
+}
|
|
|
+
|
|
|
func (db *DataBase) SaveShip(ship *Ship) error {
|
|
|
result := db.DB.Save(ship)
|
|
|
return result.Error
|
|
@@ -123,11 +151,13 @@ type User struct {
|
|
|
Name string `gorm:"unique"` // Nickname, commonly used
|
|
|
RealName string `gorm:"UniqueIndex,colate:nocase"` // BBS Realname used to identify User, typically not used/displayed
|
|
|
// Currency-likes
|
|
|
- Xp uint64 // How experienced the User is, determines how tough random opponents will be
|
|
|
- Metal uint64 // Common Currency
|
|
|
- Circuit uint64 // Rare Currency
|
|
|
- Rockets uint64 // Not a currency, a weapon, but there is technically no limit except the number that can be fired per "special" attack
|
|
|
- Fuel uint64 // Not a currency, amount of fights left (A normal fight will consume 2, a fight where you run away is 3, and a fight where you died consumes all but 1 and kicks you off)
|
|
|
+ Xp uint64 // How experienced the User is, determines how tough random opponents will be
|
|
|
+ Metal uint64 // Common Currency
|
|
|
+ Circuit uint64 // Rare Currency
|
|
|
+ MetalBanked uint64 // Metal stored in the Bank, so it won't get lost
|
|
|
+ CircuitBanked uint64 // Circuit stored in the Bank, so it won't get lost
|
|
|
+ Rockets uint64 // Not a currency, a weapon, but there is technically no limit except the number that can be fired per "special" attack
|
|
|
+ Fuel uint64 // Not a currency, amount of fights left (A normal fight will consume 2, a fight where you run away is 3, and a fight where you died consumes all but 1 and kicks you off)
|
|
|
// Stuff
|
|
|
Ship *Ship
|
|
|
// Use UpdatedAt as LastOn
|