Skip to content

Commit

Permalink
Fix 23152: Bribre going back in hand + gameinfo
Browse files Browse the repository at this point in the history
  • Loading branch information
thinkbeforecoding committed Aug 28, 2020
1 parent 7afa934 commit ad31714
Show file tree
Hide file tree
Showing 9 changed files with 1,046 additions and 40 deletions.
35 changes: 22 additions & 13 deletions Peeble.fsx
Original file line number Diff line number Diff line change
Expand Up @@ -646,6 +646,7 @@ type PhpCompiler =
mutable DecisionTargets: (Fable.Ident list * Fable.Expr) list
mutable LocalVars: string Set
mutable CapturedVars: Capture Set
mutable MutableVars: string Set
mutable Id: int
}
static member empty =
Expand All @@ -660,13 +661,17 @@ type PhpCompiler =
DecisionTargets = []
LocalVars = Set.empty
CapturedVars = Set.empty
MutableVars = Set.empty
Id = 0
}
member this.AddType(phpType: PhpType) =
this.Types <- Map.add phpType.Name phpType this.Types
phpType

member this.AddLocalVar(var) =
member this.AddLocalVar(var, isMutable) =
if isMutable then
this.MutableVars <- Set.add var this.MutableVars

if this.CapturedVars.Contains(Capture.ByRef var) then
()
elif this.CapturedVars.Contains(Capture.ByValue var) then
Expand All @@ -676,9 +681,13 @@ type PhpCompiler =

member this.UseVar(var) =
if not (Set.contains var this.LocalVars) && not (Set.contains (ByRef var) this.CapturedVars) then
this.CapturedVars <- Set.add (ByValue var) this.CapturedVars
if Set.contains var this.MutableVars then
this.CapturedVars <- Set.add (ByRef var) this.CapturedVars
else
this.CapturedVars <- Set.add (ByValue var) this.CapturedVars

member this.UseVarByRef(var) =
this.MutableVars <- Set.add var this.MutableVars
if not (Set.contains var this.LocalVars) && not (Set.contains (ByValue var) this.CapturedVars) then
this.CapturedVars <- Set.add (ByRef var) this.CapturedVars

Expand Down Expand Up @@ -1092,7 +1101,7 @@ let rec convertExpr (ctx: PhpCompiler) (expr: Fable.Expr) =

let innerCtx = ctx.NewScope()
for id in bindings do
innerCtx.AddLocalVar(fixName id.Name)
innerCtx.AddLocalVar(fixName id.Name, id.IsMutable)
let body = convertExprToStatement innerCtx target Return
for capturedVar in innerCtx.CapturedVars do
ctx.UseVar(capturedVar)
Expand All @@ -1118,7 +1127,7 @@ let rec convertExpr (ctx: PhpCompiler) (expr: Fable.Expr) =
| Fable.Let(bindings, body) ->
let innerCtx = ctx.NewScope()
for id,_ in bindings do
innerCtx.AddLocalVar(fixName id.Name)
innerCtx.AddLocalVar(fixName id.Name, id.IsMutable)
let body = convertExprToStatement innerCtx expr Return
for capturedVar in innerCtx.CapturedVars do
ctx.UseVar(capturedVar)
Expand Down Expand Up @@ -1158,12 +1167,12 @@ and convertFunction (ctx: PhpCompiler) kind body =
match kind with
| Fable.Lambda(arg) ->
let argName = fixName arg.Name
scope.AddLocalVar argName
scope.AddLocalVar(argName, arg.IsMutable)
[argName]
| Fable.Delegate(args) ->
[ for arg in args do
let argName = fixName arg.Name
scope.AddLocalVar argName
scope.AddLocalVar(argName, arg.IsMutable)
argName ]

let phpBody = convertExprToStatement scope body Return
Expand Down Expand Up @@ -1271,11 +1280,11 @@ and convertMatching ctx input guard thenExpr elseExpr expr returnStrategy =

phpCase,
[ for ident, binding in List.zip idents bindings do
ctx.AddLocalVar(fixName ident.Name)
ctx.AddLocalVar(fixName ident.Name, ident.IsMutable)
Assign(PhpVar(fixName ident.Name, None), convertExpr ctx binding)
match returnStrategy with
| Target t ->
ctx.AddLocalVar(fixName t)
ctx.AddLocalVar(fixName t, false)
Assign(PhpVar(fixName t, None), PhpConst(PhpConstNumber(float i)))
Break;
| Return _ ->
Expand Down Expand Up @@ -1343,15 +1352,15 @@ and convertExprToStatement ctx expr returnStrategy =
| _ ->
let idents,target = ctx.DecisionTargets.[index]
[ for ident, boundValue in List.zip idents boundValues do
ctx.AddLocalVar(fixName ident.Name)
ctx.AddLocalVar(fixName ident.Name, ident.IsMutable)
Assign(PhpVar(fixName ident.Name, None), convertExpr ctx boundValue)
yield! convertExprToStatement ctx target returnStrategy ]

| Fable.Let(bindings,body) ->
[
for ident, expr in bindings do
let name = fixName ident.Name
ctx.AddLocalVar(name)
ctx.AddLocalVar(name, ident.IsMutable)
yield! convertExprToStatement ctx expr (Let name)
yield! convertExprToStatement ctx body returnStrategy ]

Expand All @@ -1370,7 +1379,7 @@ and convertExprToStatement ctx expr returnStrategy =
let left = convertExpr ctx expr
match left with
| PhpVar(v,_) ->
ctx.AddLocalVar(v)
ctx.AddLocalVar(v, true)
| _ -> ()
[ Assign(left, convertExpr ctx value)]

Expand All @@ -1379,7 +1388,7 @@ and convertExprToStatement ctx expr returnStrategy =
match returnStrategy with
| Return -> [ PhpStatement.Return (convertExpr ctx expr) ]
| Let(var) ->
ctx.AddLocalVar(var)
ctx.AddLocalVar(var, false)
[ Assign(PhpVar(var,None), convertExpr ctx expr) ]
| Do -> [ PhpStatement.Do (convertExpr ctx expr) ]
| Target _ -> failwithf "Target should be assigned by decisiontree success"
Expand Down Expand Up @@ -1459,7 +1468,7 @@ let fs =
for d in convertDecl phpComp decl do
i,d
]
convertDecl phpComp asts.[1].Declarations.[51]
convertDecl phpComp asts.[1].Declarations.[216]

let w = new StringWriter()
let ctx = Output.Writer.create w
Expand Down
13 changes: 7 additions & 6 deletions bga/gameinfos.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,12 @@
'players' => array( 2,3,4 ),

// Suggest players to play with this number of players. Must be null if there is no such advice, or if there is only one possible player configuration.
'suggest_player_number' => null,
'suggest_player_number' => 2,

// Discourage players to play with these numbers of players. Must be null if there is no such advice.
'not_recommend_player_number' => null,
// 'not_recommend_player_number' => array( 2, 3 ), // <= example: this is not recommended to play this game with 2 or 3 players


// Estimated game duration, in minutes (used only for the launch, afterward the real duration is computed)
'estimated_duration' => 30,

Expand All @@ -73,7 +72,7 @@
'losers_not_ranked' => false,

// Game is "beta". A game MUST set is_beta=1 when published on BGA for the first time, and must remains like this until all bugs are fixed.
'is_beta' => 1,
'is_beta' => 0,

// Is this game cooperative (all players wins together or loose together)
'is_coop' => 0,
Expand Down Expand Up @@ -124,7 +123,9 @@
// A good length for this text is between 100 and 150 words (about 6 to 9 lines on a standard display)
'presentation' => array(

totranslate("Crazy Farmers And The Clotures Electriques is an equally accessible and wacky game,
totranslate("Crazy Farmers And The Clôtures Electriques is a strong emerging strategy game (2p)
which tends to be more lightweight and chaotic in 3-4p (better around a table with friends and a good drink in this mode).
In any case it’s a game with a pinch of « take that » and cutthroat maneuvers
where you’ll get to experience the best UFC games ever. As you may wonder, UFC stands
for Ultimate Farming Championship. In 2042, the European Union has long since cut off
financial aid to farmers. In order to get out of this situation, farmers created a competition for
Expand All @@ -145,7 +146,7 @@
// http://en.doc.boardgamearena.com/Game_meta-information:_gameinfos.inc.php
// IMPORTANT: this list should be ORDERED, with the most important tag first.
// IMPORTANT: it is mandatory that the FIRST tag is 1, 2, 3 and 4 (= game category)
'tags' => array( 3, 11, 105),
'tags' => array( 3, 11, 30, 105, 206),


//////// BGA SANDBOX ONLY PARAMETERS (DO NOT MODIFY)
Expand All @@ -160,7 +161,7 @@

'custom_buy_button' => array(
'url' => 'https://www.kickstarter.com/projects/1486112993/crazy-farmers-and-the-clotures-electriques?ref=2fs2c4&fbclid=IwAR3yHCuZJy6sawaRPWm0V2wUk2zOHi8etQhsSYObWVg8Y952VWI-zcCYG2k',
'label' => totranslate('KickStarter now')
'label' => totranslate('KickStarter')
)

);
20 changes: 10 additions & 10 deletions bga/modules/crazyfarmers.php
Original file line number Diff line number Diff line change
Expand Up @@ -4619,8 +4619,8 @@ function Shared_002EPlayer___decide($otherPlayers__1, $barns__3, $hayBales__4, $
}));
}));
default:
$activePatternResult1216 = Shared_002EFenceOps____007CRwd_007C__007C($nextPath__1, $player__17->Fence);
if (!is_null($activePatternResult1216)) {
$activePatternResult27975 = Shared_002EFenceOps____007CRwd_007C__007C($nextPath__1, $player__17->Fence);
if (!is_null($activePatternResult27975)) {
return new Cons(new Event_FenceRemoved(new Moved($cmd__1->Direction, $nextPath__1, $nextPos__1)), FSharpList::get_Nil());
} else {
$matchValue__26 = Shared_002EFenceModule___findLoop($cmd__1->Direction, $player__17->Tractor, $player__17->Fence);
Expand Down Expand Up @@ -6157,7 +6157,7 @@ function Shared_002EBoardModule___findBridgeParcels($field__12) {
$d0__1 = $time__1;
$time__1 = $time__1 + 1;
$isRoot = Util::equals($parent__1, $parcel__7);
$step = function ($dir__17, $tupledArg__8) use ($d0__1, $isRoot, $parcel__7, $parent__1, $patternInput__8, $visited__1, &$cut__1, &$loop__7) {
$step = function ($dir__17, $tupledArg__8) use ($d0__1, $isRoot, $parcel__7, $parent__1, $patternInput__8, &$cut__1, &$loop__7, &$visited__1) {
$neighbor__3 = Shared_002EParcel___op_Addition__ZF6EFE4B($parcel__7, $dir__17);
if (Set::contains($neighbor__3, $patternInput__8->parcels)) {
$matchValue__41 = $neighbor__3;
Expand Down Expand Up @@ -6868,9 +6868,9 @@ function Shared_002EBoardModule___decide($cmd__5, $state__8) {
}
}, $tupledArg__12[0], $tupledArg__12[1]);
$tupledArg__14 = Shared_002EBoardModule___cont(function ($board__39, $_arg3__3) { return FSharpList::ofSeq(Seq::delay(function ($unitVar__65) use ($board__39) { return Seq::collect(function ($matchValue__61) {
$activePatternResult1508 = $matchValue__61;
if (Shared_002EFieldModule___isEmpty(Shared_002EPlayer___field($activePatternResult1508[1])) ? !Shared_002EPlayer___isKo($activePatternResult1508[1]) : false) {
return Seq::append(Seq::singleton(new BoardEvent_Played($activePatternResult1508[0], new Event_Eliminated())), Seq::delay(function ($unitVar__66) { return Seq::singleton(new BoardEvent_UndoCheckPointed());
$activePatternResult28267 = $matchValue__61;
if (Shared_002EFieldModule___isEmpty(Shared_002EPlayer___field($activePatternResult28267[1])) ? !Shared_002EPlayer___isKo($activePatternResult28267[1]) : false) {
return Seq::append(Seq::singleton(new BoardEvent_Played($activePatternResult28267[0], new Event_Eliminated())), Seq::delay(function ($unitVar__66) { return Seq::singleton(new BoardEvent_UndoCheckPointed());
}));
} else {
return Seq::empty();
Expand Down Expand Up @@ -7172,8 +7172,8 @@ function Shared_002EBoardModule___toState($board__53) {
}, $source__13);
return FSharpArray::ofSeq($source__14);
})(), new STable($board__53->Item2->Table->Players, $board__53->Item2->Table->AllPlayers, FSharpArray::ofSeq(Seq::delay(function ($unitVar__75) use ($board__53) { return Seq::collect(function ($matchValue__68) {
$activePatternResult1549 = $matchValue__68;
return Seq::singleton([ $activePatternResult1549[0], $activePatternResult1549[1]]);
$activePatternResult28308 = $matchValue__68;
return Seq::singleton([ $activePatternResult28308[0], $activePatternResult28308[1]]);
}, $board__53->Item2->Table->Names);
})), $board__53->Item2->Table->Current), FSharpArray::ofList($board__53->Item2->DiscardPile), Shared_002EHandModule___count($board__53->Item2->DrawPile), (function () use ($board__53) {
$list__33 = Shared_002EFieldModule___parcels($board__53->Item2->Barns->Free);
Expand All @@ -7190,8 +7190,8 @@ function Shared_002EBoardModule___toState($board__53) {
}, $source__11);
return FSharpArray::ofSeq($source__12);
})(), new STable($board__53->Item->Table->Players, $board__53->Item->Table->AllPlayers, FSharpArray::ofSeq(Seq::delay(function ($unitVar__74) use ($board__53) { return Seq::collect(function ($matchValue__67) {
$activePatternResult1545 = $matchValue__67;
return Seq::singleton([ $activePatternResult1545[0], $activePatternResult1545[1]]);
$activePatternResult28304 = $matchValue__67;
return Seq::singleton([ $activePatternResult28304[0], $activePatternResult28304[1]]);
}, $board__53->Item->Table->Names);
})), $board__53->Item->Table->Current), FSharpArray::ofList($board__53->Item->DiscardPile), Shared_002EHandModule___count($board__53->Item->DrawPile), (function () use ($board__53) {
$list__31 = Shared_002EFieldModule___parcels($board__53->Item->Barns->Free);
Expand Down
Binary file modified crazy.sln
Binary file not shown.
2 changes: 1 addition & 1 deletion debug-webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ var commonPlugins = [
];
var bgaPlugins = [
new HtmlWebpackPlugin({
filename: 'game/bga.html',
filename: 'bga.html',
template: resolve('./src/Debugger/index.html'),
excludeChunks: ['join', 'game', 'joinstyle']
})
Expand Down
20 changes: 10 additions & 10 deletions php/lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -4619,8 +4619,8 @@ function Shared_002EPlayer___decide($otherPlayers__1, $barns__3, $hayBales__4, $
}));
}));
default:
$activePatternResult1216 = Shared_002EFenceOps____007CRwd_007C__007C($nextPath__1, $player__17->Fence);
if (!is_null($activePatternResult1216)) {
$activePatternResult27975 = Shared_002EFenceOps____007CRwd_007C__007C($nextPath__1, $player__17->Fence);
if (!is_null($activePatternResult27975)) {
return new Cons(new Event_FenceRemoved(new Moved($cmd__1->Direction, $nextPath__1, $nextPos__1)), FSharpList::get_Nil());
} else {
$matchValue__26 = Shared_002EFenceModule___findLoop($cmd__1->Direction, $player__17->Tractor, $player__17->Fence);
Expand Down Expand Up @@ -6157,7 +6157,7 @@ function Shared_002EBoardModule___findBridgeParcels($field__12) {
$d0__1 = $time__1;
$time__1 = $time__1 + 1;
$isRoot = Util::equals($parent__1, $parcel__7);
$step = function ($dir__17, $tupledArg__8) use ($d0__1, $isRoot, $parcel__7, $parent__1, $patternInput__8, $visited__1, &$cut__1, &$loop__7) {
$step = function ($dir__17, $tupledArg__8) use ($d0__1, $isRoot, $parcel__7, $parent__1, $patternInput__8, &$cut__1, &$loop__7, &$visited__1) {
$neighbor__3 = Shared_002EParcel___op_Addition__ZF6EFE4B($parcel__7, $dir__17);
if (Set::contains($neighbor__3, $patternInput__8->parcels)) {
$matchValue__41 = $neighbor__3;
Expand Down Expand Up @@ -6868,9 +6868,9 @@ function Shared_002EBoardModule___decide($cmd__5, $state__8) {
}
}, $tupledArg__12[0], $tupledArg__12[1]);
$tupledArg__14 = Shared_002EBoardModule___cont(function ($board__39, $_arg3__3) { return FSharpList::ofSeq(Seq::delay(function ($unitVar__65) use ($board__39) { return Seq::collect(function ($matchValue__61) {
$activePatternResult1508 = $matchValue__61;
if (Shared_002EFieldModule___isEmpty(Shared_002EPlayer___field($activePatternResult1508[1])) ? !Shared_002EPlayer___isKo($activePatternResult1508[1]) : false) {
return Seq::append(Seq::singleton(new BoardEvent_Played($activePatternResult1508[0], new Event_Eliminated())), Seq::delay(function ($unitVar__66) { return Seq::singleton(new BoardEvent_UndoCheckPointed());
$activePatternResult28267 = $matchValue__61;
if (Shared_002EFieldModule___isEmpty(Shared_002EPlayer___field($activePatternResult28267[1])) ? !Shared_002EPlayer___isKo($activePatternResult28267[1]) : false) {
return Seq::append(Seq::singleton(new BoardEvent_Played($activePatternResult28267[0], new Event_Eliminated())), Seq::delay(function ($unitVar__66) { return Seq::singleton(new BoardEvent_UndoCheckPointed());
}));
} else {
return Seq::empty();
Expand Down Expand Up @@ -7172,8 +7172,8 @@ function Shared_002EBoardModule___toState($board__53) {
}, $source__13);
return FSharpArray::ofSeq($source__14);
})(), new STable($board__53->Item2->Table->Players, $board__53->Item2->Table->AllPlayers, FSharpArray::ofSeq(Seq::delay(function ($unitVar__75) use ($board__53) { return Seq::collect(function ($matchValue__68) {
$activePatternResult1549 = $matchValue__68;
return Seq::singleton([ $activePatternResult1549[0], $activePatternResult1549[1]]);
$activePatternResult28308 = $matchValue__68;
return Seq::singleton([ $activePatternResult28308[0], $activePatternResult28308[1]]);
}, $board__53->Item2->Table->Names);
})), $board__53->Item2->Table->Current), FSharpArray::ofList($board__53->Item2->DiscardPile), Shared_002EHandModule___count($board__53->Item2->DrawPile), (function () use ($board__53) {
$list__33 = Shared_002EFieldModule___parcels($board__53->Item2->Barns->Free);
Expand All @@ -7190,8 +7190,8 @@ function Shared_002EBoardModule___toState($board__53) {
}, $source__11);
return FSharpArray::ofSeq($source__12);
})(), new STable($board__53->Item->Table->Players, $board__53->Item->Table->AllPlayers, FSharpArray::ofSeq(Seq::delay(function ($unitVar__74) use ($board__53) { return Seq::collect(function ($matchValue__67) {
$activePatternResult1545 = $matchValue__67;
return Seq::singleton([ $activePatternResult1545[0], $activePatternResult1545[1]]);
$activePatternResult28304 = $matchValue__67;
return Seq::singleton([ $activePatternResult28304[0], $activePatternResult28304[1]]);
}, $board__53->Item->Table->Names);
})), $board__53->Item->Table->Current), FSharpArray::ofList($board__53->Item->DiscardPile), Shared_002EHandModule___count($board__53->Item->DrawPile), (function () use ($board__53) {
$list__31 = Shared_002EFieldModule___parcels($board__53->Item->Barns->Free);
Expand Down
Loading

0 comments on commit ad31714

Please sign in to comment.