econode

package module
v0.0.0-...-0988b43 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 29, 2023 License: MIT Imports: 17 Imported by: 0

README

this was stupid if anyone thinks something else, joins the server and actually say something to maybe revive the project

Econode

💸 Server-based incremental idle game.

Join my Discord at https://discord.gg/3PDdcQz

Econode is an idle incremental game (think like Cookie Clicker, or the Cafe Discord bot) implemented as a Server to Client game where you compete with others in the Econetwork (Econode server) to have the highest earning Econode.

⚠ Econode is mostly in the concepting/alpha stage right now. Beware!
This means that things like the database format, Go API and protocol will change A LOT.

Setup

For testing, you can run an Econode server. To build the server, just run go build ./cmd/econode-server

Documentation

Econode has documention for several things: its Websocket protocol, formulas and item prices.

They are located in the docs folder.
There is NO GUARANTEED STABILITY for ANY documents currently.

License

The reference Econode server and client implementations are licensed under the MIT license.
Read here for more info.

Documentation

Index

Constants

View Source
const EconetworkMOTD = "Hello!!!"

TODO: make better motd kek

Variables

View Source
var (
	ErrAccountNotExists   = errors.New("account doesnt exist")   // for when trying to login or get account
	ErrAccountExists      = errors.New("account already exists") // trying to register an already existing username/account
	ErrMissingCredentials = errors.New("neither username or password were provided")
)
View Source
var (
	ItemUnknown       Item
	ItemQuark         = Item{0.05, 50, "Quark", 0}
	ItemElectron      = Item{0.1, 120, "Electron", 0}
	ItemTransistor    = Item{0.04, 175, "Transistor", 0}
	ItemLogicCircuit  = Item{2, 220, "Logic Circuit", 0}
	ItemBreadboard    = Item{2.7, 275, "Breadboard", 0}
	ItemFPGA          = Item{3, 330, "FPGA", 0}
	ItemCPU           = Item{4.2, 405, "CPU", 0}
	ItemEmbeddedPC    = Item{490, 4.9, "Embedded Computer", 0}
	ItemSmartphone    = Item{640, 5.6, "Smartphone", 0}
	ItemLaptop        = Item{780, 6.4, "Laptop", 0}
	ItemDesktop       = Item{955, 7, "Desktop", 0}
	ItemWindowsServer = Item{1128, 8.7, "Windows Server", 0}
	ItemLinuxServer   = Item{1200, 9.1, "Linux Server", 0}
	ItemMainframe     = Item{1500, 10.2, "Mainframe", 0}
	// Rebirth 2
	ItemQuantumPC             = Item{10000, 22, "Quantum Computer", 0}
	ItemLunarQuantumFarm      = Item{22000, 32, "Lunar Quantum Farm", 0}
	ItemComputingSolarSystem  = Item{34000, 44, "Computing Solar System", 0}
	ItemQuantumGalaxy         = Item{50000, 56, "Quantum Galaxy", 0}
	ItemComputationalUniverse = Item{75000, 69, "Computational Universe", 0}
)
View Source
var (
	ErrNotEnoughMoney = errors.New("not enough money to do this")
)

Functions

func SessionID

func SessionID() string

Generates a session id for a user

Types

type Account

type Account struct {
	Username string `db:"username"`
	ID       int    `db:"id"`
	Node     *Node  // pointer since a person won't have a node immediately on register
	Op       bool   `db:"op"`
	Network  *Econetwork
}

A client's account

func (*Account) GetNode

func (a *Account) GetNode() *Node

type AccountInfoPayload

type AccountInfoPayload struct {
	Username string `json:"username"`
	ID       int    `json:"id"`
	Node     int    `json:"nodeID"`
	Op       bool   `json:"op"`
}

type Auction

type Auction struct {
	Type         AuctionType
	BasePrice    float64
	SellingPrice float64
}

type AuctionType

type AuctionType int
const (
	AuctionGem AuctionType = 1
)

type AuthPayload

type AuthPayload struct {
	Password string `json:"password"`
	Username string `json:"username"`
}

For register and login methods

type Client

type Client struct {
	Account   *Account
	Conn      *websocket.Conn
	SessionID string
}

func (*Client) Outgoing

func (c *Client) Outgoing(method string, data interface{})

func (*Client) SendError

func (c *Client) SendError(method string, data interface{})

func (*Client) SendFail

func (c *Client) SendFail(method string, data interface{})

func (*Client) SendForbidden

func (c *Client) SendForbidden(method string, data interface{})

func (*Client) SendMalformed

func (c *Client) SendMalformed(method string)

func (*Client) SendSuccess

func (c *Client) SendSuccess(method string, data interface{})

type ClientResponse

type ClientResponse struct {
	SessionID string       `json:"sessionID"`
	Method    string       `json:"method"`
	Data      *interface{} `json:"data,omitempty"`
}

Fields we should expect from the client

type Econetwork

type Econetwork struct {
	Address string
	// contains filtered or unexported fields
}

func New

func New() (*Econetwork, error)

func (*Econetwork) CreateNode

func (e *Econetwork) CreateNode(name string, owner *Account)

func (*Econetwork) Dump

func (e *Econetwork) Dump()

func (*Econetwork) GetNode

func (e *Econetwork) GetNode(id int) *Node

func (*Econetwork) GetNodeByName

func (e *Econetwork) GetNodeByName(name string) *Node

func (*Econetwork) Start

func (e *Econetwork) Start()

func (*Econetwork) Stop

func (e *Econetwork) Stop()

type EconodeInfoPayload

type EconodeInfoPayload struct {
	Name    string  `json:"name"`
	Owner   int     `json:"ownerID"`
	Balance float64 `json:"balance"`
}

type Item

type Item struct {
	CPS   float64
	Price float64
	Name  string
	Count float64
}

func (*Item) String

func (i *Item) String() string

type ItemPurchasePayload

type ItemPurchasePayload struct {
	ItemName string  `json:"itemName"`
	Amount   float64 `json:"amount"`
}

type Node

type Node struct {
	ID      int    `db:"id"`
	Name    string `db:"name"`
	OwnerID int    `db:"owner"`
	Owner   *Account

	Members []int

	Inventory map[string]Item
	Balance   float64 `db:"balance"`
	Gems      int     `db:"gems"`
	Multi     float64 `db:"multi"`
	// contains filtered or unexported fields
}

Someone's econode The idea is that we can have other people growing a single node together

func NewNode

func NewNode(name string, ownerAcc *Account) *Node

func (*Node) Buy

func (n *Node) Buy(purchase Item, amount float64) error

func (*Node) CPS

func (n *Node) CPS() float64

func (*Node) Collect

func (n *Node) Collect()

func (*Node) Store

func (n *Node) Store() []Item

Store returns a list of items that the node can buy. TODO: restrict list of items based on certain criteria

type ServerResponse

type ServerResponse struct {
	Code   string       `json:"code"`
	Method string       `json:"method"`
	Data   *interface{} `json:"data,omitempty"`
}

The server response struct What we should send, as defined by the procotol

type StatsPayload

type StatsPayload struct {
	Nodes          int    `json:"nodes"`
	Accounts       int    `json:"accounts"`
	NetworkVersion string `json:"networkVersion"`
}

type UserMessagePayload

type UserMessagePayload struct {
	User    string `json:"username"`
	Message string `json:"message"`
}

type WelcomePayload

type WelcomePayload struct {
	MOTD string `json:"motd"`
}

Directories

Path Synopsis
cmd
econode command
econode-server command

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL