works on claims
This commit is contained in:
237
main.js
237
main.js
@@ -5334,9 +5334,9 @@ var $elm$core$Task$perform = F2(
|
||||
A2($elm$core$Task$map, toMessage, task)));
|
||||
});
|
||||
var $elm$browser$Browser$application = _Browser_application;
|
||||
var $author$project$Main$Model = F5(
|
||||
function (state, player, loot, groupLoot, merchantItems) {
|
||||
return {groupLoot: groupLoot, loot: loot, merchantItems: merchantItems, player: player, state: state};
|
||||
var $author$project$Main$Model = F7(
|
||||
function (state, player, claims, notification, loot, groupLoot, merchantItems) {
|
||||
return {claims: claims, groupLoot: groupLoot, loot: loot, merchantItems: merchantItems, notification: notification, player: player, state: state};
|
||||
});
|
||||
var $author$project$Main$PlayerChest = {$: 'PlayerChest'};
|
||||
var $author$project$Main$State = F6(
|
||||
@@ -6186,6 +6186,31 @@ var $author$project$Main$fetchShopInventory = $elm$http$Http$get(
|
||||
$author$project$Main$valueDecoder($author$project$Main$lootDecoder)),
|
||||
url: 'http://localhost:8088/api/items'
|
||||
});
|
||||
var $author$project$Main$GotClaims = F2(
|
||||
function (a, b) {
|
||||
return {$: 'GotClaims', a: a, b: b};
|
||||
});
|
||||
var $author$project$Main$Claim = F3(
|
||||
function (id, player_id, loot_id) {
|
||||
return {id: id, loot_id: loot_id, player_id: player_id};
|
||||
});
|
||||
var $author$project$Main$claimDecoder = A4(
|
||||
$elm$json$Json$Decode$map3,
|
||||
$author$project$Main$Claim,
|
||||
A2($elm$json$Json$Decode$field, 'id', $elm$json$Json$Decode$int),
|
||||
A2($elm$json$Json$Decode$field, 'player_id', $elm$json$Json$Decode$int),
|
||||
A2($elm$json$Json$Decode$field, 'loot_id', $elm$json$Json$Decode$int));
|
||||
var $author$project$Main$fetchClaims = function (playerId) {
|
||||
return $elm$http$Http$get(
|
||||
{
|
||||
expect: A2(
|
||||
$elm$http$Http$expectJson,
|
||||
$author$project$Main$GotClaims(playerId),
|
||||
$author$project$Main$valueDecoder(
|
||||
$elm$json$Json$Decode$list($author$project$Main$claimDecoder))),
|
||||
url: 'http://localhost:8088/api/claims'
|
||||
});
|
||||
};
|
||||
var $author$project$Main$OfPlayer = {$: 'OfPlayer'};
|
||||
var $author$project$Main$fetchLoot = function (id) {
|
||||
return $elm$http$Http$get(
|
||||
@@ -6230,7 +6255,8 @@ var $author$project$Main$initPlayer = function (id) {
|
||||
_List_fromArray(
|
||||
[
|
||||
$author$project$Main$fetchPlayer(id),
|
||||
$author$project$Main$fetchLoot(id)
|
||||
$author$project$Main$fetchLoot(id),
|
||||
$author$project$Main$fetchClaims(id)
|
||||
]));
|
||||
};
|
||||
var $author$project$Main$fetchInitialData = function (playerId) {
|
||||
@@ -6487,10 +6513,12 @@ var $author$project$Main$init = F3(
|
||||
}
|
||||
}();
|
||||
return _Utils_Tuple2(
|
||||
A5(
|
||||
A7(
|
||||
$author$project$Main$Model,
|
||||
A6($author$project$Main$State, key, route, '', false, $elm$core$Maybe$Nothing, $elm$core$Maybe$Nothing),
|
||||
$author$project$Main$blankPlayer,
|
||||
_List_Nil,
|
||||
$elm$core$Maybe$Nothing,
|
||||
$elm$core$Maybe$Nothing,
|
||||
$elm$core$Maybe$Nothing,
|
||||
$elm$core$Maybe$Nothing),
|
||||
@@ -6903,6 +6931,12 @@ var $author$project$Main$setError = F2(
|
||||
{error: error})
|
||||
});
|
||||
});
|
||||
var $author$project$Main$setNotification = F2(
|
||||
function (notification, model) {
|
||||
return _Utils_update(
|
||||
model,
|
||||
{notification: notification});
|
||||
});
|
||||
var $elm$core$Set$remove = F2(
|
||||
function (key, _v0) {
|
||||
var dict = _v0.a;
|
||||
@@ -7044,6 +7078,32 @@ var $author$project$Main$update = F2(
|
||||
model),
|
||||
$elm$core$Platform$Cmd$none);
|
||||
}
|
||||
case 'GotClaims':
|
||||
var id = msg.a;
|
||||
var result = msg.b;
|
||||
if (result.$ === 'Ok') {
|
||||
var claims = result.a;
|
||||
return _Utils_Tuple2(
|
||||
_Utils_update(
|
||||
model,
|
||||
{
|
||||
claims: A2(
|
||||
$elm$core$List$filter,
|
||||
function (c) {
|
||||
return _Utils_eq(c.player_id, id);
|
||||
},
|
||||
claims)
|
||||
}),
|
||||
$elm$core$Platform$Cmd$none);
|
||||
} else {
|
||||
var error = result.a;
|
||||
return _Utils_Tuple2(
|
||||
A2(
|
||||
$author$project$Main$setError,
|
||||
'Fetching claims...' + $elm$core$Debug$toString(error),
|
||||
model),
|
||||
$elm$core$Platform$Cmd$none);
|
||||
}
|
||||
case 'GotLoot':
|
||||
var dest = msg.a;
|
||||
var result = msg.b;
|
||||
@@ -7115,11 +7175,15 @@ var $author$project$Main$update = F2(
|
||||
return $elm$core$Maybe$Nothing;
|
||||
} else {
|
||||
if (newMode.a.$ === 'Grab') {
|
||||
var _v8 = newMode.a;
|
||||
var _v9 = newMode.a;
|
||||
return $elm$core$Maybe$Just(
|
||||
$elm$core$Set$fromList(
|
||||
_List_fromArray(
|
||||
[34, 38])));
|
||||
A2(
|
||||
$elm$core$List$map,
|
||||
function (c) {
|
||||
return c.loot_id;
|
||||
},
|
||||
model.claims)));
|
||||
} else {
|
||||
var others = newMode.a;
|
||||
return $elm$core$Maybe$Just($elm$core$Set$empty);
|
||||
@@ -7148,15 +7212,23 @@ var $author$project$Main$update = F2(
|
||||
tracker: $elm$core$Maybe$Nothing,
|
||||
url: 'http://localhost:8088/api/players/' + (playerId + '/events/last')
|
||||
}));
|
||||
default:
|
||||
case 'GotActionResult':
|
||||
var response = msg.a;
|
||||
if (response.$ === 'Ok') {
|
||||
var result = response.a;
|
||||
var updates = A2($elm$core$Maybe$withDefault, _List_Nil, result.updates);
|
||||
var notification = result.notification;
|
||||
var errors = A2($elm$core$Maybe$withDefault, '', result.errors);
|
||||
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));
|
||||
A2(
|
||||
$author$project$Main$setError,
|
||||
errors,
|
||||
A2(
|
||||
$author$project$Main$setNotification,
|
||||
notification,
|
||||
A3($elm$core$List$foldl, $author$project$Main$applyUpdate, model, updates))));
|
||||
} else {
|
||||
var r = response.a;
|
||||
return _Utils_Tuple2(
|
||||
@@ -7166,6 +7238,12 @@ var $author$project$Main$update = F2(
|
||||
model),
|
||||
$elm$core$Platform$Cmd$none);
|
||||
}
|
||||
default:
|
||||
return _Utils_Tuple2(
|
||||
_Utils_update(
|
||||
model,
|
||||
{notification: $elm$core$Maybe$Nothing}),
|
||||
$elm$core$Platform$Cmd$none);
|
||||
}
|
||||
});
|
||||
var $author$project$Main$UndoLastAction = {$: 'UndoLastAction'};
|
||||
@@ -7304,16 +7382,64 @@ var $author$project$Main$controlsWhenRoute = function (route) {
|
||||
}
|
||||
};
|
||||
var $elm$html$Html$hr = _VirtualDom_node('hr');
|
||||
var $author$project$Main$renderId = function (item) {
|
||||
return A2(
|
||||
$elm$html$Html$p,
|
||||
_List_Nil,
|
||||
_List_fromArray(
|
||||
[
|
||||
$elm$html$Html$text(
|
||||
$elm$core$String$fromInt(item.id))
|
||||
]));
|
||||
};
|
||||
var $elm$core$List$any = F2(
|
||||
function (isOkay, list) {
|
||||
any:
|
||||
while (true) {
|
||||
if (!list.b) {
|
||||
return false;
|
||||
} else {
|
||||
var x = list.a;
|
||||
var xs = list.b;
|
||||
if (isOkay(x)) {
|
||||
return true;
|
||||
} else {
|
||||
var $temp$isOkay = isOkay,
|
||||
$temp$list = xs;
|
||||
isOkay = $temp$isOkay;
|
||||
list = $temp$list;
|
||||
continue any;
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
var $author$project$Main$itemInClaims = F2(
|
||||
function (claims, item) {
|
||||
return A2(
|
||||
$elm$core$List$any,
|
||||
function (c) {
|
||||
return _Utils_eq(c.loot_id, item.id);
|
||||
},
|
||||
claims);
|
||||
});
|
||||
var $author$project$Main$renderIcon = F2(
|
||||
function (name, size) {
|
||||
return A2(
|
||||
$elm$html$Html$span,
|
||||
_List_fromArray(
|
||||
[
|
||||
$elm$html$Html$Attributes$class('icon is-medium')
|
||||
]),
|
||||
_List_fromArray(
|
||||
[
|
||||
A2(
|
||||
$elm$html$Html$i,
|
||||
_List_fromArray(
|
||||
[
|
||||
$elm$html$Html$Attributes$class(name + (' fa-' + size))
|
||||
]),
|
||||
_List_Nil)
|
||||
]));
|
||||
});
|
||||
var $author$project$Main$renderIfClaimed = F2(
|
||||
function (isClaimed, item) {
|
||||
var _v0 = isClaimed(item);
|
||||
if (_v0) {
|
||||
return A2($author$project$Main$renderIcon, 'fas fa-praying-hands', '1x');
|
||||
} else {
|
||||
return $elm$html$Html$text('');
|
||||
}
|
||||
});
|
||||
var $author$project$Main$LootViewItemSwitched = function (a) {
|
||||
return {$: 'LootViewItemSwitched', a: a};
|
||||
};
|
||||
@@ -7563,7 +7689,7 @@ var $author$project$Main$stackedIcon = function (name) {
|
||||
$elm$html$Html$span,
|
||||
_List_fromArray(
|
||||
[
|
||||
$elm$html$Html$Attributes$class('icon is-large has-text-dark')
|
||||
$elm$html$Html$Attributes$class('icon is-medium')
|
||||
]),
|
||||
_List_fromArray(
|
||||
[
|
||||
@@ -7589,7 +7715,7 @@ var $author$project$Main$stackedIcon = function (name) {
|
||||
$elm$html$Html$Attributes$class(name + ' fa-inverse fa-stack-1x')
|
||||
]),
|
||||
_List_Nil),
|
||||
$elm$html$Html$text(name)
|
||||
$elm$html$Html$text('')
|
||||
]))
|
||||
]));
|
||||
};
|
||||
@@ -7717,6 +7843,17 @@ var $author$project$Main$viewDebugSection = function (model) {
|
||||
$elm$html$Html$text(
|
||||
'Selection : ' + $elm$core$Debug$toString(model.state.selection))
|
||||
])),
|
||||
A2(
|
||||
$elm$html$Html$p,
|
||||
_List_fromArray(
|
||||
[
|
||||
$elm$html$Html$Attributes$class('panel-block')
|
||||
]),
|
||||
_List_fromArray(
|
||||
[
|
||||
$elm$html$Html$text(
|
||||
'Claims : ' + $elm$core$Debug$toString(model.claims))
|
||||
])),
|
||||
A2($elm$html$Html$p, _List_Nil, $author$project$Main$debugSandbox)
|
||||
]));
|
||||
};
|
||||
@@ -7735,25 +7872,6 @@ var $elm$html$Html$Attributes$href = function (url) {
|
||||
_VirtualDom_noJavaScriptUri(url));
|
||||
};
|
||||
var $elm$html$Html$nav = _VirtualDom_node('nav');
|
||||
var $author$project$Main$renderIcon = F2(
|
||||
function (name, size) {
|
||||
return A2(
|
||||
$elm$html$Html$span,
|
||||
_List_fromArray(
|
||||
[
|
||||
$elm$html$Html$Attributes$class('icon is-medium')
|
||||
]),
|
||||
_List_fromArray(
|
||||
[
|
||||
A2(
|
||||
$elm$html$Html$i,
|
||||
_List_fromArray(
|
||||
[
|
||||
$elm$html$Html$Attributes$class(name + (' fa-' + size))
|
||||
]),
|
||||
_List_Nil)
|
||||
]));
|
||||
});
|
||||
var $author$project$Main$viewHeaderBar = function (model) {
|
||||
return A2(
|
||||
$elm$html$Html$nav,
|
||||
@@ -7879,6 +7997,32 @@ var $author$project$Main$viewHeaderBar = function (model) {
|
||||
]))
|
||||
]));
|
||||
};
|
||||
var $author$project$Main$ClearNotification = {$: 'ClearNotification'};
|
||||
var $author$project$Main$viewNotification = function (notification) {
|
||||
if (notification.$ === 'Just') {
|
||||
var t = notification.a;
|
||||
return A2(
|
||||
$elm$html$Html$div,
|
||||
_List_fromArray(
|
||||
[
|
||||
$elm$html$Html$Attributes$class('notification is-success is-marginless')
|
||||
]),
|
||||
_List_fromArray(
|
||||
[
|
||||
A2(
|
||||
$elm$html$Html$button,
|
||||
_List_fromArray(
|
||||
[
|
||||
$elm$html$Html$Attributes$class('delete'),
|
||||
$elm$html$Html$Events$onClick($author$project$Main$ClearNotification)
|
||||
]),
|
||||
_List_Nil),
|
||||
$elm$html$Html$text(t)
|
||||
]));
|
||||
} else {
|
||||
return $elm$html$Html$text('');
|
||||
}
|
||||
};
|
||||
var $elm$core$String$cons = _String_cons;
|
||||
var $elm$core$String$fromChar = function (_char) {
|
||||
return A2($elm$core$String$cons, _char, '');
|
||||
@@ -7973,8 +8117,8 @@ var $author$project$Main$viewWealth = function (wealth) {
|
||||
$elm$core$String$fromInt(wealth.cp))
|
||||
]);
|
||||
};
|
||||
var $author$project$Main$viewPlayerBar = F2(
|
||||
function (player, actionControls) {
|
||||
var $author$project$Main$viewPlayerBar = F3(
|
||||
function (player, notification, actionControls) {
|
||||
return A2(
|
||||
$elm$html$Html$section,
|
||||
_List_fromArray(
|
||||
@@ -8043,6 +8187,7 @@ var $author$project$Main$viewPlayerBar = F2(
|
||||
]))
|
||||
]))
|
||||
]) : _List_Nil))),
|
||||
$author$project$Main$viewNotification(notification),
|
||||
A2(
|
||||
$elm$html$Html$div,
|
||||
_List_fromArray(
|
||||
@@ -8099,7 +8244,9 @@ var $author$project$Main$view = function (model) {
|
||||
function () {
|
||||
var _v4 = model.state.route;
|
||||
if (_v4.$ === 'GroupLoot') {
|
||||
return $elm$core$Maybe$Just($author$project$Main$renderId);
|
||||
return $elm$core$Maybe$Just(
|
||||
$author$project$Main$renderIfClaimed(
|
||||
$author$project$Main$itemInClaims(model.claims)));
|
||||
} else {
|
||||
return $elm$core$Maybe$Nothing;
|
||||
}
|
||||
@@ -8112,7 +8259,7 @@ var $author$project$Main$view = function (model) {
|
||||
body: _List_fromArray(
|
||||
[
|
||||
$author$project$Main$viewHeaderBar(model),
|
||||
A2($author$project$Main$viewPlayerBar, model.player, headerControls),
|
||||
A3($author$project$Main$viewPlayerBar, model.player, model.notification, headerControls),
|
||||
A2(
|
||||
$elm$html$Html$article,
|
||||
_List_fromArray(
|
||||
|
||||
Reference in New Issue
Block a user