impls Item and Wealth updates
This commit is contained in:
268
main.js
268
main.js
@@ -6509,8 +6509,8 @@ var $author$project$Main$ModeSwitched = function (a) {
|
||||
return {$: 'ModeSwitched', a: a};
|
||||
};
|
||||
var $author$project$Main$ApiResponse = F4(
|
||||
function (value, updates, notification, error) {
|
||||
return {error: error, notification: notification, updates: updates, value: value};
|
||||
function (value, notification, updates, errors) {
|
||||
return {errors: errors, notification: notification, updates: updates, value: value};
|
||||
});
|
||||
var $elm$json$Json$Decode$oneOf = _Json_oneOf;
|
||||
var $elm$json$Json$Decode$maybe = function (decoder) {
|
||||
@@ -6596,15 +6596,82 @@ var $author$project$Main$apiResponseDecoder = A5(
|
||||
$author$project$Main$ApiResponse,
|
||||
$elm$json$Json$Decode$maybe(
|
||||
A2($elm$json$Json$Decode$field, 'value', $elm$json$Json$Decode$string)),
|
||||
$elm$json$Json$Decode$maybe(
|
||||
A2($elm$json$Json$Decode$field, 'notification', $elm$json$Json$Decode$string)),
|
||||
$elm$json$Json$Decode$maybe(
|
||||
A2(
|
||||
$elm$json$Json$Decode$field,
|
||||
'updates',
|
||||
$elm$json$Json$Decode$list($author$project$Main$updatesDecoder))),
|
||||
$elm$json$Json$Decode$maybe(
|
||||
A2($elm$json$Json$Decode$field, 'notification', $elm$json$Json$Decode$string)),
|
||||
$elm$json$Json$Decode$maybe(
|
||||
A2($elm$json$Json$Decode$field, 'error', $elm$json$Json$Decode$string)));
|
||||
A2($elm$json$Json$Decode$field, 'errors', $elm$json$Json$Decode$string)));
|
||||
var $elm$core$List$filter = F2(
|
||||
function (isGood, list) {
|
||||
return A3(
|
||||
$elm$core$List$foldr,
|
||||
F2(
|
||||
function (x, xs) {
|
||||
return isGood(x) ? A2($elm$core$List$cons, x, xs) : xs;
|
||||
}),
|
||||
_List_Nil,
|
||||
list);
|
||||
});
|
||||
var $elm$core$Basics$neq = _Utils_notEqual;
|
||||
var $elm$core$Maybe$withDefault = F2(
|
||||
function (_default, maybe) {
|
||||
if (maybe.$ === 'Just') {
|
||||
var value = maybe.a;
|
||||
return value;
|
||||
} else {
|
||||
return _default;
|
||||
}
|
||||
});
|
||||
var $author$project$Main$applyUpdate = F2(
|
||||
function (u, model) {
|
||||
switch (u.$) {
|
||||
case 'ItemRemoved':
|
||||
var item = u.a;
|
||||
return _Utils_update(
|
||||
model,
|
||||
{
|
||||
loot: $elm$core$Maybe$Just(
|
||||
A2(
|
||||
$elm$core$List$filter,
|
||||
function (i) {
|
||||
return !_Utils_eq(i.id, item.id);
|
||||
},
|
||||
A2($elm$core$Maybe$withDefault, _List_Nil, model.loot)))
|
||||
});
|
||||
case 'ItemAdded':
|
||||
var item = u.a;
|
||||
return _Utils_update(
|
||||
model,
|
||||
{
|
||||
loot: $elm$core$Maybe$Just(
|
||||
A2(
|
||||
$elm$core$List$cons,
|
||||
item,
|
||||
A2($elm$core$Maybe$withDefault, _List_Nil, model.loot)))
|
||||
});
|
||||
case 'WealthUpdated':
|
||||
var diff = u.a;
|
||||
var player = model.player;
|
||||
var wealth = player.wealth;
|
||||
return _Utils_update(
|
||||
model,
|
||||
{
|
||||
player: _Utils_update(
|
||||
player,
|
||||
{
|
||||
wealth: A4($author$project$Main$Wealth, wealth.cp + diff.cp, wealth.sp + diff.sp, wealth.gp + diff.gp, wealth.pp + diff.pp)
|
||||
})
|
||||
});
|
||||
case 'ClaimAdded':
|
||||
return model;
|
||||
default:
|
||||
return model;
|
||||
}
|
||||
});
|
||||
var $elm$core$Set$Set_elm_builtin = function (a) {
|
||||
return {$: 'Set_elm_builtin', a: a};
|
||||
};
|
||||
@@ -6628,17 +6695,6 @@ var $author$project$Main$printError = function (error) {
|
||||
}
|
||||
};
|
||||
var $elm$browser$Browser$Navigation$pushUrl = _Browser_pushUrl;
|
||||
var $elm$core$List$filter = F2(
|
||||
function (isGood, list) {
|
||||
return A3(
|
||||
$elm$core$List$foldr,
|
||||
F2(
|
||||
function (x, xs) {
|
||||
return isGood(x) ? A2($elm$core$List$cons, x, xs) : xs;
|
||||
}),
|
||||
_List_Nil,
|
||||
list);
|
||||
});
|
||||
var $elm$json$Json$Encode$int = _Json_wrap;
|
||||
var $elm$core$Maybe$map = F2(
|
||||
function (f, maybe) {
|
||||
@@ -6664,15 +6720,6 @@ var $elm$core$Set$member = F2(
|
||||
var dict = _v0.a;
|
||||
return A2($elm$core$Dict$member, key, dict);
|
||||
});
|
||||
var $elm$core$Maybe$withDefault = F2(
|
||||
function (_default, maybe) {
|
||||
if (maybe.$ === 'Just') {
|
||||
var value = maybe.a;
|
||||
return value;
|
||||
} else {
|
||||
return _default;
|
||||
}
|
||||
});
|
||||
var $author$project$Main$itemInSelection = F2(
|
||||
function (selection, item) {
|
||||
return A2(
|
||||
@@ -6825,7 +6872,9 @@ var $author$project$Main$sendRequest = F2(
|
||||
'http://localhost:8088/api/players/' + ($elm$core$String$fromInt(model.player.id) + '/loot'),
|
||||
'DELETE');
|
||||
default:
|
||||
return _Utils_Tuple2('http://', 'POST');
|
||||
return _Utils_Tuple2(
|
||||
'http://localhost:8088/api/players/' + ($elm$core$String$fromInt(model.player.id) + '/claims'),
|
||||
'POST');
|
||||
}
|
||||
}();
|
||||
var endpoint = _v1.a;
|
||||
@@ -6938,7 +6987,7 @@ var $author$project$Main$update = F2(
|
||||
} else {
|
||||
var href = urlRequest.a;
|
||||
return _Utils_Tuple2(
|
||||
A2($author$project$Main$setError, 'Invalid request \'' + (href + '\''), model),
|
||||
A2($author$project$Main$setError, 'External request \'' + (href + '\''), model),
|
||||
$elm$core$Platform$Cmd$none);
|
||||
}
|
||||
case 'UrlChanged':
|
||||
@@ -7102,13 +7151,12 @@ var $author$project$Main$update = F2(
|
||||
default:
|
||||
var response = msg.a;
|
||||
if (response.$ === 'Ok') {
|
||||
var r = response.a;
|
||||
return _Utils_Tuple2(
|
||||
A2(
|
||||
$author$project$Main$setError,
|
||||
$elm$core$Debug$toString(r),
|
||||
model),
|
||||
$elm$core$Platform$Cmd$none);
|
||||
var result = response.a;
|
||||
var updates = A2($elm$core$Maybe$withDefault, _List_Nil, result.updates);
|
||||
return A2(
|
||||
$author$project$Main$update,
|
||||
$author$project$Main$ModeSwitched($elm$core$Maybe$Nothing),
|
||||
A3($elm$core$List$foldl, $author$project$Main$applyUpdate, model, updates));
|
||||
} else {
|
||||
var r = response.a;
|
||||
return _Utils_Tuple2(
|
||||
@@ -7120,10 +7168,6 @@ var $author$project$Main$update = F2(
|
||||
}
|
||||
}
|
||||
});
|
||||
var $author$project$Main$Buy = {$: 'Buy'};
|
||||
var $author$project$Main$ConfirmAction = {$: 'ConfirmAction'};
|
||||
var $author$project$Main$Grab = {$: 'Grab'};
|
||||
var $author$project$Main$Sell = {$: 'Sell'};
|
||||
var $author$project$Main$UndoLastAction = {$: 'UndoLastAction'};
|
||||
var $elm$html$Html$button = _VirtualDom_node('button');
|
||||
var $elm$json$Json$Encode$string = _Json_wrap;
|
||||
@@ -7164,7 +7208,7 @@ var $author$project$Main$actionButton = F4(
|
||||
$elm$html$Html$button,
|
||||
_List_fromArray(
|
||||
[
|
||||
$elm$html$Html$Attributes$class('button is-' + color),
|
||||
$elm$html$Html$Attributes$class('button level-item is-' + color),
|
||||
$elm$html$Html$Events$onClick(msg)
|
||||
]),
|
||||
_List_fromArray(
|
||||
@@ -7195,7 +7239,70 @@ var $author$project$Main$actionButton = F4(
|
||||
]));
|
||||
});
|
||||
var $elm$html$Html$article = _VirtualDom_node('article');
|
||||
var $elm$html$Html$div = _VirtualDom_node('div');
|
||||
var $author$project$Main$ConfirmAction = {$: 'ConfirmAction'};
|
||||
var $author$project$Main$controlsWhenModeActive = function (mode) {
|
||||
return _List_fromArray(
|
||||
[
|
||||
A4($author$project$Main$actionButton, $author$project$Main$ConfirmAction, 'Valider', 'check', 'primary'),
|
||||
A4(
|
||||
$author$project$Main$actionButton,
|
||||
$author$project$Main$ModeSwitched($elm$core$Maybe$Nothing),
|
||||
'Annuler',
|
||||
'times',
|
||||
'danger')
|
||||
]);
|
||||
};
|
||||
var $author$project$Main$Buy = {$: 'Buy'};
|
||||
var $author$project$Main$Grab = {$: 'Grab'};
|
||||
var $author$project$Main$Sell = {$: 'Sell'};
|
||||
var $author$project$Main$controlsWhenRoute = function (route) {
|
||||
switch (route.$) {
|
||||
case 'PlayerChest':
|
||||
return _List_fromArray(
|
||||
[
|
||||
A4(
|
||||
$author$project$Main$actionButton,
|
||||
$author$project$Main$ModeSwitched(
|
||||
$elm$core$Maybe$Just($author$project$Main$Sell)),
|
||||
'Vendre',
|
||||
'coins',
|
||||
'danger')
|
||||
]);
|
||||
case 'GroupLoot':
|
||||
return _List_fromArray(
|
||||
[
|
||||
A4(
|
||||
$author$project$Main$actionButton,
|
||||
$author$project$Main$ModeSwitched(
|
||||
$elm$core$Maybe$Just($author$project$Main$Grab)),
|
||||
'Demander',
|
||||
'praying-hands',
|
||||
'primary')
|
||||
]);
|
||||
case 'Merchant':
|
||||
return _List_fromArray(
|
||||
[
|
||||
A4(
|
||||
$author$project$Main$actionButton,
|
||||
$author$project$Main$ModeSwitched(
|
||||
$elm$core$Maybe$Just($author$project$Main$Buy)),
|
||||
'Acheter',
|
||||
'coins',
|
||||
'success')
|
||||
]);
|
||||
default:
|
||||
return _List_fromArray(
|
||||
[
|
||||
A4(
|
||||
$author$project$Main$actionButton,
|
||||
$author$project$Main$ModeSwitched(
|
||||
$elm$core$Maybe$Just($author$project$Main$Add)),
|
||||
'Nouveau loot',
|
||||
'plus',
|
||||
'primary')
|
||||
]);
|
||||
}
|
||||
};
|
||||
var $elm$html$Html$hr = _VirtualDom_node('hr');
|
||||
var $author$project$Main$renderId = function (item) {
|
||||
return A2(
|
||||
@@ -7231,6 +7338,7 @@ var $elm$html$Html$Attributes$boolProperty = F2(
|
||||
$elm$json$Json$Encode$bool(bool));
|
||||
});
|
||||
var $elm$html$Html$Attributes$checked = $elm$html$Html$Attributes$boolProperty('checked');
|
||||
var $elm$html$Html$div = _VirtualDom_node('div');
|
||||
var $elm$core$String$fromFloat = _String_fromNumber;
|
||||
var $elm$html$Html$input = _VirtualDom_node('input');
|
||||
var $elm$json$Json$Decode$at = F2(
|
||||
@@ -7979,84 +8087,18 @@ var $author$project$Main$view = function (model) {
|
||||
if (_v3.$ === 'Just') {
|
||||
var mode = _v3.a;
|
||||
return _Utils_Tuple2(
|
||||
_List_fromArray(
|
||||
[
|
||||
A2(
|
||||
$elm$html$Html$div,
|
||||
_List_fromArray(
|
||||
[
|
||||
$elm$html$Html$Attributes$class('buttons has-addons')
|
||||
]),
|
||||
_List_fromArray(
|
||||
[
|
||||
A4($author$project$Main$actionButton, $author$project$Main$ConfirmAction, 'Valider', 'success', 'primary'),
|
||||
A4(
|
||||
$author$project$Main$actionButton,
|
||||
$author$project$Main$ModeSwitched($elm$core$Maybe$Nothing),
|
||||
'Annuler',
|
||||
'times',
|
||||
'danger')
|
||||
]))
|
||||
]),
|
||||
$author$project$Main$controlsWhenModeActive(mode),
|
||||
$elm$core$Maybe$Just(
|
||||
A2($author$project$Main$rowControlsForMode, mode, isSelected)));
|
||||
} else {
|
||||
return _Utils_Tuple2(
|
||||
A2(
|
||||
$elm$core$List$cons,
|
||||
A4($author$project$Main$actionButton, $author$project$Main$UndoLastAction, 'Annuler action', 'delete', 'danger'),
|
||||
function () {
|
||||
var _v4 = model.state.route;
|
||||
switch (_v4.$) {
|
||||
case 'PlayerChest':
|
||||
return _List_fromArray(
|
||||
[
|
||||
A4(
|
||||
$author$project$Main$actionButton,
|
||||
$author$project$Main$ModeSwitched(
|
||||
$elm$core$Maybe$Just($author$project$Main$Sell)),
|
||||
'Vendre',
|
||||
'coins',
|
||||
'danger')
|
||||
]);
|
||||
case 'GroupLoot':
|
||||
return _List_fromArray(
|
||||
[
|
||||
A4(
|
||||
$author$project$Main$actionButton,
|
||||
$author$project$Main$ModeSwitched(
|
||||
$elm$core$Maybe$Just($author$project$Main$Grab)),
|
||||
'Demander',
|
||||
'coins',
|
||||
'primary')
|
||||
]);
|
||||
case 'Merchant':
|
||||
return _List_fromArray(
|
||||
[
|
||||
A4(
|
||||
$author$project$Main$actionButton,
|
||||
$author$project$Main$ModeSwitched(
|
||||
$elm$core$Maybe$Just($author$project$Main$Buy)),
|
||||
'Acheter',
|
||||
'coins',
|
||||
'success')
|
||||
]);
|
||||
default:
|
||||
return _List_fromArray(
|
||||
[
|
||||
A4(
|
||||
$author$project$Main$actionButton,
|
||||
$author$project$Main$ModeSwitched(
|
||||
$elm$core$Maybe$Just($author$project$Main$Add)),
|
||||
'Nouveau loot',
|
||||
'plus',
|
||||
'primary')
|
||||
]);
|
||||
}
|
||||
}()),
|
||||
A4($author$project$Main$actionButton, $author$project$Main$UndoLastAction, 'Annuler action', 'backspace', 'danger'),
|
||||
$author$project$Main$controlsWhenRoute(model.state.route)),
|
||||
function () {
|
||||
var _v5 = model.state.route;
|
||||
if (_v5.$ === 'GroupLoot') {
|
||||
var _v4 = model.state.route;
|
||||
if (_v4.$ === 'GroupLoot') {
|
||||
return $elm$core$Maybe$Just($author$project$Main$renderId);
|
||||
} else {
|
||||
return $elm$core$Maybe$Nothing;
|
||||
@@ -8064,13 +8106,13 @@ var $author$project$Main$view = function (model) {
|
||||
}());
|
||||
}
|
||||
}();
|
||||
var actionControls = _v2.a;
|
||||
var headerControls = _v2.a;
|
||||
var rowControls = _v2.b;
|
||||
return {
|
||||
body: _List_fromArray(
|
||||
[
|
||||
$author$project$Main$viewHeaderBar(model),
|
||||
A2($author$project$Main$viewPlayerBar, model.player, actionControls),
|
||||
A2($author$project$Main$viewPlayerBar, model.player, headerControls),
|
||||
A2(
|
||||
$elm$html$Html$article,
|
||||
_List_fromArray(
|
||||
|
||||
Reference in New Issue
Block a user