aboutsummaryrefslogtreecommitdiff
path: root/src/stats.rs
blob: d679c3e7d38cf22af97b423facc68d3225af0f2a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
//! This file contains balancing data
//!
//! Each type of node and packet is being balanced for different
//! factors.  The stats are just returned by these functions.
//! Whenever there is some effect that can happen in the game, it's
//! value (strength) will be derived from here.

/// The cost of doing business
pub mod cost {
    use crate::data::{Level, PacketType, Upgrade};

    /// Takes the current node and desired upgrade level
    pub fn upgrade(curr: &Upgrade, want: &Upgrade) -> u32 {
        use self::{Level::*, Upgrade::*};
        match (curr, want) {
            // Base upgrades
            (Base, Guard(One)) => 30,
            (Base, Compute(One)) => 25,
            (Base, Relay(One)) => 20,

            // Guards
            (Guard(One), Guard(Two)) => 50,
            (Guard(Two), Guard(Three)) => 75,

            // Compute is expensive
            (Compute(One), Compute(Two)) => 50,
            (Compute(Two), Compute(Three)) => 95,

            // Relays
            (Relay(One), Relay(Two)) => 35,
            (Relay(Two), Relay(Three)) => 55,

            // Can't touch this
            (_, _) => unreachable!(),
        }
    }

    /// Sending certain packets costs money, let's find out how much
    pub fn packets(node: &Upgrade, packet: &PacketType) -> u32 {
        use {
            Level::*,
            PacketType::*,
            Upgrade::{Base, Compute as Cc, Guard, Relay},
        };
        match (node, packet) {
            // Sending pings is free forever
            (_, Ping) => 0,
            // Capture packets always cost the same
            (_, Capture) => 15,

            // The cost of compute packets increases with levels
            // because their efficiency increases more dramatically
            (Cc(One), Compute { .. }) => 7,
            (Cc(Two), Compute { .. }) => 14,
            (Cc(Three), Compute { .. }) => 21,

            // Payloads can only be sent from guards
            (Guard(_), Payload { .. }) => 12,

            // Resets are relatively cheap
            (Guard(One), Reset) => 16,
            (Guard(Two), Reset) => 32,
            (Guard(Three), Reset) => 48,

            (Guard(One), Nitm) => 28,
            (Guard(Two), Nitm) => 64,
            (Guard(Three), Nitm) => 148,

            (Guard(One), Virus) => 18,
            (Guard(Two), Virus) => 40,
            (Guard(Three), Virus) => 60,

            // Only level 3 guards can send takeovers
            (Guard(Three), TakeOver) => 256,

            // Can't touch this
            (_, _) => unreachable!()
        }
    }
}