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
81
82
83
84
85
86
87
88
89
90
91
92module Duets.Simulation.Tests.Interactions.Exercise
open Duets.Entities
open FsUnit
open NUnit.Framework
open Test.Common
open Test.Common.Generators
open Duets.Common
open Duets.Data
open Duets.Simulation
open Duets.Simulation.Interactions
let initialState = State.generateOne State.defaultOptions
let state =
let character = initialState |> Queries.Characters.playableCharacter
initialState
|> State.Characters.setAttribute character.Id CharacterAttribute.Health 50
[<Test>]
let ``exercising in non-gym equipment is not allowed`` () =
[ Items.Drink.Beer.alhambra
Items.Furniture.Bed.ikeaBed
Items.Furniture.Stove.lgStove ]
|> List.iter (fun item ->
Items.perform state (fst item) ItemInteraction.Exercise
|> Result.unwrapError
|> should equal Items.ActionNotPossible)
[<Test>]
let ``exercising in gym equipment decreases energy`` () =
Items.perform
state
(fst Items.Gym.Treadmills.elliptical)
ItemInteraction.Exercise
|> Result.unwrap
|> List.item 1
|> function
| CharacterAttributeChanged(_, attr, amount) ->
attr |> should equal CharacterAttribute.Energy
amount |> should equal (Diff(100, 90))
| _ -> failwith "Effect was not of correct type"
[<Test>]
let ``exercising in gym equipment increases health`` () =
Items.perform
state
(fst Items.Gym.Treadmills.elliptical)
ItemInteraction.Exercise
|> Result.unwrap
|> List.item 2
|> function
| CharacterAttributeChanged(_, attr, amount) ->
attr |> should equal CharacterAttribute.Health
amount |> should equal (Diff(50, 58))
| _ -> failwith "Effect was not of correct type"
[<Test>]
let ``exercising in gym equipment increases skill if chance succeeds`` () =
use _ = changeToStaticRandom 10
Items.perform
state
(fst Items.Gym.Treadmills.elliptical)
ItemInteraction.Exercise
|> Result.unwrap
|> List.item 3
|> function
| SkillImproved(_, Diff(_, (skill, level))) ->
skill.Id |> should equal SkillId.Fitness
level |> should equal 1
| _ -> failwith "Effect was not of correct type"
[<Test>]
let ``exercising in gym equipment does not increase skill if chance does not succeed``
()
=
use _ = changeToStaticRandom 100
Items.perform
state
(fst Items.Gym.Treadmills.elliptical)
ItemInteraction.Exercise
|> Result.unwrap
|> List.filter (function
| SkillImproved _ -> true
| _ -> false)
|> should haveLength 0