Browse Source

init project

documentation-add
Arthur POULET 5 years ago
commit
4a5ef59a98
No known key found for this signature in database GPG Key ID: 7C42395DCA99B923
  1. 10
      .gitignore
  2. 1
      .travis.yml
  3. 21
      LICENSE
  4. 41
      README.md
  5. 7
      shard.yml
  6. 22
      spec/die.cr
  7. 0
      spec/fixed_value.cr
  8. 10
      spec/pathfinder_spec.cr
  9. 0
      spec/roll.cr
  10. 2
      spec/spec_helper.cr
  11. 5
      src/pathfinder.cr
  12. 30
      src/pathfinder/die.cr
  13. 11
      src/pathfinder/fixed_value.cr
  14. 28
      src/pathfinder/roll.cr
  15. 3
      src/pathfinder/version.cr

10
.gitignore

@ -0,0 +1,10 @@
/doc/
/libs/
/.crystal/
/.shards/
# Libraries don't need dependency lock
# Dependencies will be locked in application that uses them
/shard.lock

1
.travis.yml

@ -0,0 +1 @@
language: crystal

21
LICENSE

@ -0,0 +1,21 @@
The MIT License (MIT)
Copyright (c) 2016 Arthur Poulet
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

41
README.md

@ -0,0 +1,41 @@
# pathfinder
TODO: Write a description here
## Installation
Add this to your application's `shard.yml`:
```yaml
dependencies:
pathfinder:
github: Nephos/crystal_pathfinder
```
## Usage
```crystal
require "pathfinder"
```
TODO: Write usage instructions here
## Development
TODO: Write development instructions here
## Contributing
1. Fork it ( https://github.com/Nephos/crystal_pathfinder/fork )
2. Create your feature branch (git checkout -b my-new-feature)
3. Commit your changes (git commit -am 'Add some feature')
4. Push to the branch (git push origin my-new-feature)
5. Create a new Pull Request
## Contributors
- [Nephos](https://github.com/Nephos) Arthur Poulet - creator, maintainer

7
shard.yml

@ -0,0 +1,7 @@
name: pathfinder
version: 0.1.0
authors:
- Arthur Poulet <arthur.poulet@mailoo.org>
license: MIT

22
spec/die.cr

@ -0,0 +1,22 @@
describe Pathfinder::Die do
it "initialize" do
Pathfinder::Die.new(1..20).should be_a(Pathfinder::Die)
Pathfinder::Die.new(10..20).should be_a(Pathfinder::Die)
Pathfinder::Die.new(20).should be_a(Pathfinder::Die)
end
it "min max" do
Pathfinder::Die.new(1..1).min.should eq 1
Pathfinder::Die.new(1..1).max.should eq 1
Pathfinder::Die.new(1..20).min.should eq 1
Pathfinder::Die.new(1..20).max.should eq 20
end
it "test" do
100.times do
min = rand 1..10
max = rand min..20
((min..max).includes? Pathfinder::Die.new(min..max).test).should eq(true)
end
end
end

0
spec/fixed_value.cr

10
spec/pathfinder_spec.cr

@ -0,0 +1,10 @@
require "./spec_helper"
require "./die"
require "./fixed_value"
require "./roll"
describe Pathfinder do
it "works" do
false.should eq(false)
end
end

0
spec/roll.cr

2
spec/spec_helper.cr

@ -0,0 +1,2 @@
require "spec"
require "../src/pathfinder"

5
src/pathfinder.cr

@ -0,0 +1,5 @@
require "./pathfinder/*"
module Pathfinder
# TODO Put your code here
end

30
src/pathfinder/die.cr

@ -0,0 +1,30 @@
module Pathfinder
class Die
@faces : Range(Int32, Int32)
def initialize(@faces)
end
def initialize(nb_faces : Int32)
@faces = 1..nb_faces
end
def average : Float64
@faces.reduce{|r, l| r + l }.to_f64 / @faces.size
end
def max : Int32
@faces.end
end
def min : Int32
@faces.begin
end
def test : Int32
@faces.to_a.sample
end
end
end

11
src/pathfinder/fixed_value.cr

@ -0,0 +1,11 @@
require "./die"
module Pathfinder
class FixedValue < Die
def initialize(value : Int32)
super(value..value)
end
end
end

28
src/pathfinder/roll.cr

@ -0,0 +1,28 @@
require "./die"
require "./fixed_value"
module Pathfinder
class Roll
@dice : Array(Die)
def initialize(@dice)
end
def self.parse(str : String)
end
def min : Int32
@dice.map{|d| d.min }.sum
end
def max : Int32
@dice.map{|d| d.max }.sum
end
def test : Int32
@dice.map{|d| d.test }.sum
end
end
end

3
src/pathfinder/version.cr

@ -0,0 +1,3 @@
module Pathfinder
VERSION = "0.1.0"
end
Loading…
Cancel
Save