Giter VIP home page Giter VIP logo

dice's People

Contributors

eduardostalinho avatar frenata avatar justinian avatar olavmueller avatar silkeh avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

dice's Issues

embedded fmt.Stringer

This isn't necessarily an issue so much as an attempt at understanding the code, but why is the RollResult interface defined with the embedded interface fmt.Stringer. As far as I know this is functionally equivalent to String() string in the interface definition, yes?

Anyway, thanks for the library more generally, I was sitting down thinking of some ideas for CLI helper tools for running some RPGs and realized that a first start was a parser/roller for '3d6' style strings, but figured I better check to make sure someone else hadn't done it first before potentially replicating a lot of work!

add to RollResult interface: Int() int

I'm not particular about the name of said function, but I tried to find a simple way to retrieve 'just the total' from a StdResult and saw that there was an exported function Total() int, which since it's not a part of the interface requires the client to perform a type assertion along the lines of:

result, _, err := Roll("3d8")
if err!= nil { //handle it }
total := result.(StdResult).Total()

This isn't terrible, but for the purposes of when a client really just wants the simple integer result of a roll, it'd be nice to just call result.Int(). The main problem, though, is that while StdResult.Total() and VsResult.Successes() make sense as the 'simple integer' returns from a Result, I'm clueless as to whether that question even makes sense when it comes to EotE, a system I'm not familiar with.

If there's simply no reasonable simple return from EotE or this is an undesired addition, that's fine; otherwise I'm happy to make the necessary changes and send a PR if given some direction as to what kind of return that implementation should provide.

Setting Random Generator

Given the structure of dice, it looks like it would be rather trivial to set up the ability to use a custom rand. At least for each individual Roller, given they are all already structs. Setting a base/'dice global' one would be a little more tricky.
I would be willing to submit a PR if it would be accepted.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.