Skip to content

Commit

Permalink
Some TDD for Ribbit
Browse files Browse the repository at this point in the history
  • Loading branch information
MaxWilson committed Jan 5, 2024
1 parent 04a3983 commit 3878da5
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]
Add DFRPG character generation
Add Ribbit language for defining and controlling generic RPG rulesets. Declarative language centered on rolls and state manipulation via independent, scoped rules.

## [0.1.0] - 2020-12-01
First release
Expand Down
26 changes: 26 additions & 0 deletions test/Ribbit.Accept.fs
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
module Ribbit.Accept
open Expecto
open Swensen.Unquote

let bardsTaleSimple = """
number properties: HP, SP, AC, XP, GP
text properties: Name
property race: Elf, Dwarf, Human, Hobbit, Half-orc, Gnome, Half-elf
flags: Dead, Poisoned, Stoned, Insane
derived flag: OK when not Dead | Stoned | Insane
roll AttackRoll: roll-at-least on 1d20
// todo: define my current weapon, damage roll, damage type, ST, damage for ST, takeDamage
action attack (target) [requires turn when OK]:
attack: AttackRoll vs target's AC
if attack succeeds
damage: my current weapon's mode's damage roll for my ST
let injury = target.takeDamage(damage, my current weapon's mode's damage type)
if target is Dead
log "<Name> kills <target's Name>!" [attack, damage, injury, target.HP] // would auto-log all variables in scope, i.e. attack, damage, injury, but we'll be explicit here so we can include target's new HP
else
log "<Name> hits <target's Name> for <injury>" [+target.HP] // another way of specifying that we want to log target.HP even though it's not a variable
else
log "<Name> misses <target's Name>"
"""
1 change: 1 addition & 0 deletions test/test.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
<ItemGroup>
<Compile Include="Chargen.Accept.fs" />
<Compile Include="Packrat.Accept.fs" />
<Compile Include="Ribbit.Accept.fs" />
<Compile Include="Main.fs" />
</ItemGroup>

Expand Down

0 comments on commit 3878da5

Please sign in to comment.