7yl4r / the-oregon-trajectory

:rocket: The Oregon Trail -- in SPAAACE!
http://7yl4r.github.io/the-oregon-trajectory/
GNU Affero General Public License v3.0
17 stars 6 forks source link

generalized resource class #51

Open 7yl4r opened 9 years ago

7yl4r commented 9 years ago

before adding more resources, a resource class ought to be use to reduce duplication

class resource
    constructor: ()->
        @chance = 0.5  # chance of use per tick
        @expense = 1   # amount subtracted per use
        @amount   = 10 # how much you currently have

    tick: ()->
        if Math.random() < @chance
            @amount -= @expense

--- Want to back this issue? **[Post a bounty on it!](https://www.bountysource.com/issues/10360974-generalized-resource-class?utm_campaign=plugin&utm_content=tracker%2F13859664&utm_medium=issues&utm_source=github)** We accept bounties via [Bountysource](https://www.bountysource.com/?utm_campaign=plugin&utm_content=tracker%2F13859664&utm_medium=issues&utm_source=github).
BrianErikson commented 9 years ago

I'm not sure I understand the chance variable. I mean, it makes sense with radiation and other random things, but since a 'tick' is basically just time progressing, does it make sense to have a "chance" to expend fuel? I'm curious :)

7yl4r commented 9 years ago

I guess I'm thinking that it's a little fun to have some uncertainty in there so that sometimes you get lucky. It seems like it's not very noticeable as implemented though, with as many times as we're randoming it's virtually the same as * @chance .

I think we may want to reduce the frequency of ticks.

BrianErikson commented 9 years ago

Yeah I agree with that. Maybe a tick every 250ms or something? Four a second? Or we could even go more old-school with it and do two a second

7yl4r commented 9 years ago

before/during changing that (and balancing the other constants) might be a good time to address #53 too.