1 Commits

Author SHA1 Message Date
57e65e1901 Release 0.15.2 2024-07-31 15:41:39 +03:00
92 changed files with 191 additions and 403 deletions

View File

@ -12,7 +12,6 @@ jobs:
steps:
- uses: actions/checkout@v2
- name: extract version
id: version
run: echo ::set-output name=VERSION::${GITHUB_REF#refs/tags/}
@ -22,24 +21,13 @@ jobs:
with:
token: ${{ secrets.GITHUB_TOKEN }}
filter: 'Release \d+\.\d+\.\d+'
- name: setup JDK
uses: actions/setup-java@v2
with:
distribution: temurin
java-version: 18
- name: install sbt
uses: eclipse-score/apt-install@main
with:
packages: wget
- run: |
wget https://scala.jfrog.io/artifactory/debian/sbt-1.11.7.deb
sudo dpkg -i sbt-1.11.7.deb
- name: create dist
run: make dist
- name: release
uses: softprops/action-gh-release@v1
with:

View File

@ -13,20 +13,10 @@ jobs:
steps:
- uses: actions/checkout@v2
- name: setup JDK
uses: actions/setup-java@v2
with:
distribution: temurin
java-version: 18
- name: install sbt
uses: eclipse-score/apt-install@main
with:
packages: wget
- run: |
wget https://scala.jfrog.io/artifactory/debian/sbt-1.11.7.deb
sudo dpkg -i sbt-1.11.7.deb
- name: run tests
run: make tests

View File

@ -41,7 +41,7 @@
<div class="container">
<div id="toolbar">
<button class="btn btn-primary" data-bs-toggle="modal" data-bs-target="#add-loot-dialog">
<button id="add-btn" class="btn btn-primary" data-bs-toggle="modal" data-bs-target="#add-loot-dialog" hidden>
<i class="bi bi-plus"></i> add
</button>
<button class="btn btn-secondary" onclick="reload()">
@ -147,7 +147,7 @@
<div class="modal-footer">
<button type="button" class="btn btn-danger" data-bs-dismiss="modal">close</button>
<button type="button" class="btn btn-secondary" onclick="suggestLoot()">suggest</button>
<button id="add-btn" type="submit" class="btn btn-primary">add</button>
<button type="submit" class="btn btn-primary">add</button>
</div>
</form>
</div>

View File

@ -4,7 +4,7 @@ me.arcanis.ffxivbis {
include "item_data.json"
# xivapi base url, string, required
xivapi-url = "https://v2.xivapi.com"
xivapi-url = "https://xivapi.com"
# xivapi developer key, string, optional
#xivapi-key = "abcdef"
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2021-2026 Evgeniy Alekseev.
* Copyright (c) 2019-2022 Evgeniy Alekseev.
*
* This file is part of ffxivbis
* (see https://github.com/arcan1s/ffxivbis).

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2021-2026 Evgeniy Alekseev.
* Copyright (c) 2019-2022 Evgeniy Alekseev.
*
* This file is part of ffxivbis
* (see https://github.com/arcan1s/ffxivbis).

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2021-2026 Evgeniy Alekseev.
* Copyright (c) 2019-2022 Evgeniy Alekseev.
*
* This file is part of ffxivbis
* (see https://github.com/arcan1s/ffxivbis).

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2021-2026 Evgeniy Alekseev.
* Copyright (c) 2019-2022 Evgeniy Alekseev.
*
* This file is part of ffxivbis
* (see https://github.com/arcan1s/ffxivbis).

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2021-2026 Evgeniy Alekseev.
* Copyright (c) 2019-2022 Evgeniy Alekseev.
*
* This file is part of ffxivbis
* (see https://github.com/arcan1s/ffxivbis).

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2021-2026 Evgeniy Alekseev.
* Copyright (c) 2019-2022 Evgeniy Alekseev.
*
* This file is part of ffxivbis
* (see https://github.com/arcan1s/ffxivbis).

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2021-2026 Evgeniy Alekseev.
* Copyright (c) 2019-2022 Evgeniy Alekseev.
*
* This file is part of ffxivbis
* (see https://github.com/arcan1s/ffxivbis).
@ -15,7 +15,6 @@ import akka.util.Timeout
import ch.megard.akka.http.cors.scaladsl.CorsDirectives.cors
import com.typesafe.scalalogging.StrictLogging
import me.arcanis.ffxivbis.http.api.v1.RootApiV1Endpoint
import me.arcanis.ffxivbis.http.api.v2.RootApiV2Endpoint
import me.arcanis.ffxivbis.http.view.RootView
import me.arcanis.ffxivbis.messages.{BiSProviderMessage, Message}
@ -32,7 +31,6 @@ class RootEndpoint(system: ActorSystem[Nothing], storage: ActorRef[Message], pro
private val auth = AuthorizationProvider(config, storage)
private val rootApiV1Endpoint = new RootApiV1Endpoint(storage, auth, provider, config)
private val rootApiV2Endpoint = new RootApiV2Endpoint(storage, auth)
private val rootView = new RootView(auth)
private val swagger = new Swagger(config)
@ -49,7 +47,6 @@ class RootEndpoint(system: ActorSystem[Nothing], storage: ActorRef[Message], pro
pathPrefix("api") {
pathPrefix(Segment) {
case "v1" => rootApiV1Endpoint.routes
case "v2" => rootApiV2Endpoint.routes
case _ => reject
}
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2021-2026 Evgeniy Alekseev.
* Copyright (c) 2019-2022 Evgeniy Alekseev.
*
* This file is part of ffxivbis
* (see https://github.com/arcan1s/ffxivbis).

View File

@ -1,11 +1,3 @@
/*
* Copyright (c) 2021-2026 Evgeniy Alekseev.
*
* This file is part of ffxivbis
* (see https://github.com/arcan1s/ffxivbis).
*
* License: 3-clause BSD, see https://opensource.org/licenses/BSD-3-Clause
*/
package me.arcanis.ffxivbis.http
import scala.collection.immutable.HashSet
@ -20,5 +12,5 @@ trait ValidatorHelper {
object ValidatorHelper {
final val VALID_CHARACTERS = HashSet.from("!@#$%^&*()-_=+;:',./?| ")
final val VALID_CHARACTERS = HashSet.from("!@#$%^&*()-_=+;:',./? ")
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2021-2026 Evgeniy Alekseev.
* Copyright (c) 2019-2022 Evgeniy Alekseev.
*
* This file is part of ffxivbis
* (see https://github.com/arcan1s/ffxivbis).

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2021-2026 Evgeniy Alekseev.
* Copyright (c) 2019-2022 Evgeniy Alekseev.
*
* This file is part of ffxivbis
* (see https://github.com/arcan1s/ffxivbis).

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2021-2026 Evgeniy Alekseev.
* Copyright (c) 2019-2022 Evgeniy Alekseev.
*
* This file is part of ffxivbis
* (see https://github.com/arcan1s/ffxivbis).

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2021-2026 Evgeniy Alekseev.
* Copyright (c) 2019-2022 Evgeniy Alekseev.
*
* This file is part of ffxivbis
* (see https://github.com/arcan1s/ffxivbis).

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2021-2026 Evgeniy Alekseev.
* Copyright (c) 2019-2022 Evgeniy Alekseev.
*
* This file is part of ffxivbis
* (see https://github.com/arcan1s/ffxivbis).

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2021-2026 Evgeniy Alekseev.
* Copyright (c) 2019-2022 Evgeniy Alekseev.
*
* This file is part of ffxivbis
* (see https://github.com/arcan1s/ffxivbis).

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2021-2026 Evgeniy Alekseev.
* Copyright (c) 2019-2022 Evgeniy Alekseev.
*
* This file is part of ffxivbis
* (see https://github.com/arcan1s/ffxivbis).

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2021-2026 Evgeniy Alekseev.
* Copyright (c) 2019-2022 Evgeniy Alekseev.
*
* This file is part of ffxivbis
* (see https://github.com/arcan1s/ffxivbis).

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2021-2026 Evgeniy Alekseev.
* Copyright (c) 2019-2022 Evgeniy Alekseev.
*
* This file is part of ffxivbis
* (see https://github.com/arcan1s/ffxivbis).

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2021-2026 Evgeniy Alekseev.
* Copyright (c) 2019-2022 Evgeniy Alekseev.
*
* This file is part of ffxivbis
* (see https://github.com/arcan1s/ffxivbis).

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2021-2026 Evgeniy Alekseev.
* Copyright (c) 2019-2022 Evgeniy Alekseev.
*
* This file is part of ffxivbis
* (see https://github.com/arcan1s/ffxivbis).

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2021-2026 Evgeniy Alekseev.
* Copyright (c) 2019-2022 Evgeniy Alekseev.
*
* This file is part of ffxivbis
* (see https://github.com/arcan1s/ffxivbis).

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2021-2026 Evgeniy Alekseev.
* Copyright (c) 2019-2022 Evgeniy Alekseev.
*
* This file is part of ffxivbis
* (see https://github.com/arcan1s/ffxivbis).

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2021-2026 Evgeniy Alekseev.
* Copyright (c) 2019-2022 Evgeniy Alekseev.
*
* This file is part of ffxivbis
* (see https://github.com/arcan1s/ffxivbis).

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2021-2026 Evgeniy Alekseev.
* Copyright (c) 2019-2022 Evgeniy Alekseev.
*
* This file is part of ffxivbis
* (see https://github.com/arcan1s/ffxivbis).

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2021-2026 Evgeniy Alekseev.
* Copyright (c) 2019-2022 Evgeniy Alekseev.
*
* This file is part of ffxivbis
* (see https://github.com/arcan1s/ffxivbis).

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2021-2026 Evgeniy Alekseev.
* Copyright (c) 2019-2022 Evgeniy Alekseev.
*
* This file is part of ffxivbis
* (see https://github.com/arcan1s/ffxivbis).

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2021-2026 Evgeniy Alekseev.
* Copyright (c) 2019-2022 Evgeniy Alekseev.
*
* This file is part of ffxivbis
* (see https://github.com/arcan1s/ffxivbis).

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2021-2026 Evgeniy Alekseev.
* Copyright (c) 2019-2022 Evgeniy Alekseev.
*
* This file is part of ffxivbis
* (see https://github.com/arcan1s/ffxivbis).

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2021-2026 Evgeniy Alekseev.
* Copyright (c) 2019-2022 Evgeniy Alekseev.
*
* This file is part of ffxivbis
* (see https://github.com/arcan1s/ffxivbis).

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2021-2026 Evgeniy Alekseev.
* Copyright (c) 2019-2022 Evgeniy Alekseev.
*
* This file is part of ffxivbis
* (see https://github.com/arcan1s/ffxivbis).

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2021-2026 Evgeniy Alekseev.
* Copyright (c) 2019-2022 Evgeniy Alekseev.
*
* This file is part of ffxivbis
* (see https://github.com/arcan1s/ffxivbis).

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2021-2026 Evgeniy Alekseev.
* Copyright (c) 2019-2022 Evgeniy Alekseev.
*
* This file is part of ffxivbis
* (see https://github.com/arcan1s/ffxivbis).

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2021-2026 Evgeniy Alekseev.
* Copyright (c) 2019-2022 Evgeniy Alekseev.
*
* This file is part of ffxivbis
* (see https://github.com/arcan1s/ffxivbis).

View File

@ -1,11 +1,3 @@
/*
* Copyright (c) 2021-2026 Evgeniy Alekseev.
*
* This file is part of ffxivbis
* (see https://github.com/arcan1s/ffxivbis).
*
* License: 3-clause BSD, see https://opensource.org/licenses/BSD-3-Clause
*/
package me.arcanis.ffxivbis.http.api.v1.json
import me.arcanis.ffxivbis.http.ValidatorHelper

View File

@ -1,14 +0,0 @@
/*
* Copyright (c) 2021-2026 Evgeniy Alekseev.
*
* This file is part of ffxivbis
* (see https://github.com/arcan1s/ffxivbis).
*
* License: 3-clause BSD, see https://opensource.org/licenses/BSD-3-Clause
*/
package me.arcanis.ffxivbis.http.api.v2
import me.arcanis.ffxivbis.http.api.v1.{HttpHandler => HttpHandlerV1}
import me.arcanis.ffxivbis.http.api.v2.json.JsonSupport
trait HttpHandler extends HttpHandlerV1 { this: JsonSupport => }

View File

@ -1,107 +0,0 @@
/*
* Copyright (c) 2021-2026 Evgeniy Alekseev.
*
* This file is part of ffxivbis
* (see https://github.com/arcan1s/ffxivbis).
*
* License: 3-clause BSD, see https://opensource.org/licenses/BSD-3-Clause
*/
package me.arcanis.ffxivbis.http.api.v2
import akka.actor.typed.{ActorRef, Scheduler}
import akka.http.scaladsl.server.Directives._
import akka.http.scaladsl.server._
import akka.util.Timeout
import io.swagger.v3.oas.annotations.enums.ParameterIn
import io.swagger.v3.oas.annotations.media.{ArraySchema, Content, Schema}
import io.swagger.v3.oas.annotations.parameters.RequestBody
import io.swagger.v3.oas.annotations.responses.ApiResponse
import io.swagger.v3.oas.annotations.security.SecurityRequirement
import io.swagger.v3.oas.annotations.{Operation, Parameter}
import jakarta.ws.rs._
import me.arcanis.ffxivbis.http.api.v1.json.{ErrorModel, PieceModel, PlayerIdWithCountersModel}
import me.arcanis.ffxivbis.http.api.v2.json._
import me.arcanis.ffxivbis.http.helpers.LootHelper
import me.arcanis.ffxivbis.http.{Authorization, AuthorizationProvider}
import me.arcanis.ffxivbis.messages.Message
@Path("/api/v2")
class LootEndpoint(override val storage: ActorRef[Message], override val auth: AuthorizationProvider)(implicit
timeout: Timeout,
scheduler: Scheduler
) extends LootHelper
with Authorization
with JsonSupport
with HttpHandler {
def routes: Route = suggestLoot
@PUT
@Path("party/{partyId}/loot")
@Consumes(value = Array("application/json"))
@Produces(value = Array("application/json"))
@Operation(
summary = "suggest loot",
description = "Suggest loot pieces to party",
parameters = Array(
new Parameter(
name = "partyId",
in = ParameterIn.PATH,
description = "unique party ID",
example = "o3KicHQPW5b0JcOm5yI3"
),
),
requestBody = new RequestBody(
description = "piece description",
required = true,
content = Array(new Content(schema = new Schema(implementation = classOf[PieceModel])))
),
responses = Array(
new ApiResponse(
responseCode = "200",
description = "Players with counters ordered by priority to get this item",
content = Array(
new Content(
array = new ArraySchema(schema = new Schema(implementation = classOf[PlayerIdWithCountersModel])),
)
)
),
new ApiResponse(
responseCode = "400",
description = "Invalid parameters were supplied",
content = Array(new Content(schema = new Schema(implementation = classOf[ErrorModel])))
),
new ApiResponse(
responseCode = "401",
description = "Supplied authorization is invalid",
content = Array(new Content(schema = new Schema(implementation = classOf[ErrorModel])))
),
new ApiResponse(
responseCode = "403",
description = "Access is forbidden",
content = Array(new Content(schema = new Schema(implementation = classOf[ErrorModel])))
),
new ApiResponse(
responseCode = "500",
description = "Internal server error",
content = Array(new Content(schema = new Schema(implementation = classOf[ErrorModel])))
),
),
security = Array(new SecurityRequirement(name = "basic", scopes = Array("get"))),
tags = Array("loot"),
)
def suggestLoot: Route =
path("party" / Segment / "loot") { partyId =>
extractExecutionContext { implicit executionContext =>
authenticateBasicBCrypt(s"party $partyId", authGet(partyId)) { _ =>
put {
entity(as[PiecesModel]) { piece =>
onSuccess(suggestPiece(partyId, piece.toPiece)) { response =>
complete(response.map(PlayerIdWithCountersModel.fromPlayerId))
}
}
}
}
}
}
}

View File

@ -1,36 +0,0 @@
/*
* Copyright (c) 2021-2026 Evgeniy Alekseev.
*
* This file is part of ffxivbis
* (see https://github.com/arcan1s/ffxivbis).
*
* License: 3-clause BSD, see https://opensource.org/licenses/BSD-3-Clause
*/
package me.arcanis.ffxivbis.http.api.v2
import akka.actor.typed.{ActorRef, Scheduler}
import akka.http.scaladsl.server.Directives._
import akka.http.scaladsl.server.Route
import akka.util.Timeout
import me.arcanis.ffxivbis.http.AuthorizationProvider
import me.arcanis.ffxivbis.http.api.v2.json.JsonSupport
import me.arcanis.ffxivbis.messages.Message
class RootApiV2Endpoint(
storage: ActorRef[Message],
auth: AuthorizationProvider,
)(implicit
timeout: Timeout,
scheduler: Scheduler
) extends JsonSupport
with HttpHandler {
private val lootEndpoint = new LootEndpoint(storage, auth)
def routes: Route =
handleExceptions(exceptionHandler) {
handleRejections(rejectionHandler) {
lootEndpoint.routes
}
}
}

View File

@ -1,17 +0,0 @@
/*
* Copyright (c) 2021-2026 Evgeniy Alekseev.
*
* This file is part of ffxivbis
* (see https://github.com/arcan1s/ffxivbis).
*
* License: 3-clause BSD, see https://opensource.org/licenses/BSD-3-Clause
*/
package me.arcanis.ffxivbis.http.api.v2.json
import me.arcanis.ffxivbis.http.api.v1.json.{JsonSupport => JsonSupportV1}
import spray.json._
trait JsonSupport extends JsonSupportV1 {
implicit val piecesFormat: RootJsonFormat[PiecesModel] = jsonFormat1(PiecesModel.apply)
}

View File

@ -1,25 +0,0 @@
/*
* Copyright (c) 2021-2026 Evgeniy Alekseev.
*
* This file is part of ffxivbis
* (see https://github.com/arcan1s/ffxivbis).
*
* License: 3-clause BSD, see https://opensource.org/licenses/BSD-3-Clause
*/
package me.arcanis.ffxivbis.http.api.v2.json
import io.swagger.v3.oas.annotations.media.Schema
import me.arcanis.ffxivbis.http.api.v1.json.PieceModel
import me.arcanis.ffxivbis.models.Piece
case class PiecesModel(
@Schema(description = "pieces list", required = true) pieces: Seq[PieceModel],
) {
def toPiece: Seq[Piece] = pieces.map(_.toPiece)
}
object PiecesModel {
def fromPiece(pieces: Seq[Piece]): PiecesModel = PiecesModel(pieces.map(PieceModel.fromPiece))
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2021-2026 Evgeniy Alekseev.
* Copyright (c) 2019-2022 Evgeniy Alekseev.
*
* This file is part of ffxivbis
* (see https://github.com/arcan1s/ffxivbis).

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2021-2026 Evgeniy Alekseev.
* Copyright (c) 2019-2022 Evgeniy Alekseev.
*
* This file is part of ffxivbis
* (see https://github.com/arcan1s/ffxivbis).

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2021-2026 Evgeniy Alekseev.
* Copyright (c) 2019-2022 Evgeniy Alekseev.
*
* This file is part of ffxivbis
* (see https://github.com/arcan1s/ffxivbis).
@ -56,11 +56,4 @@ trait LootHelper {
scheduler: Scheduler
): Future[Seq[PlayerIdWithCounters]] =
storage.ask(SuggestLoot(partyId, piece, _)).map(_.result)
def suggestPiece(partyId: String, pieces: Seq[Piece])(implicit
executionContext: ExecutionContext,
timeout: Timeout,
scheduler: Scheduler
): Future[Seq[PlayerIdWithCounters]] =
storage.ask(SuggestMultiLoot(partyId, pieces, _)).map(_.result)
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2021-2026 Evgeniy Alekseev.
* Copyright (c) 2019-2022 Evgeniy Alekseev.
*
* This file is part of ffxivbis
* (see https://github.com/arcan1s/ffxivbis).

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2021-2026 Evgeniy Alekseev.
* Copyright (c) 2019-2022 Evgeniy Alekseev.
*
* This file is part of ffxivbis
* (see https://github.com/arcan1s/ffxivbis).

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2021-2026 Evgeniy Alekseev.
* Copyright (c) 2019-2022 Evgeniy Alekseev.
*
* This file is part of ffxivbis
* (see https://github.com/arcan1s/ffxivbis).

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2021-2026 Evgeniy Alekseev.
* Copyright (c) 2019-2022 Evgeniy Alekseev.
*
* This file is part of ffxivbis
* (see https://github.com/arcan1s/ffxivbis).

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2021-2026 Evgeniy Alekseev.
* Copyright (c) 2019-2022 Evgeniy Alekseev.
*
* This file is part of ffxivbis
* (see https://github.com/arcan1s/ffxivbis).

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2021-2026 Evgeniy Alekseev.
* Copyright (c) 2019-2022 Evgeniy Alekseev.
*
* This file is part of ffxivbis
* (see https://github.com/arcan1s/ffxivbis).
@ -69,11 +69,6 @@ object DatabaseMessage {
override val isReadOnly: Boolean = true
}
case class SuggestMultiLoot(partyId: String, pieces: Seq[Piece], replyTo: ActorRef[LootSelector.LootSelectorResult])
extends LootDatabaseMessage {
override val isReadOnly: Boolean = true
}
// party handler
trait PartyDatabaseMessage extends DatabaseMessage

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2021-2026 Evgeniy Alekseev.
* Copyright (c) 2019-2022 Evgeniy Alekseev.
*
* This file is part of ffxivbis
* (see https://github.com/arcan1s/ffxivbis).

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2021-2026 Evgeniy Alekseev.
* Copyright (c) 2019-2022 Evgeniy Alekseev.
*
* This file is part of ffxivbis
* (see https://github.com/arcan1s/ffxivbis).

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2021-2026 Evgeniy Alekseev.
* Copyright (c) 2019-2022 Evgeniy Alekseev.
*
* This file is part of ffxivbis
* (see https://github.com/arcan1s/ffxivbis).

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2021-2026 Evgeniy Alekseev.
* Copyright (c) 2019-2022 Evgeniy Alekseev.
*
* This file is part of ffxivbis
* (see https://github.com/arcan1s/ffxivbis).

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2021-2026 Evgeniy Alekseev.
* Copyright (c) 2019-2022 Evgeniy Alekseev.
*
* This file is part of ffxivbis
* (see https://github.com/arcan1s/ffxivbis).
@ -35,8 +35,8 @@ case class Party(partyDescription: PartyDescription, rules: Seq[String], players
this
}
def suggestLoot(pieces: Seq[Piece]): LootSelector.LootSelectorResult =
LootSelector(getPlayers, pieces, rules)
def suggestLoot(piece: Piece): LootSelector.LootSelectorResult =
LootSelector(getPlayers, piece, rules)
}
object Party {

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2021-2026 Evgeniy Alekseev.
* Copyright (c) 2019-2022 Evgeniy Alekseev.
*
* This file is part of ffxivbis
* (see https://github.com/arcan1s/ffxivbis).

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2021-2026 Evgeniy Alekseev.
* Copyright (c) 2019-2022 Evgeniy Alekseev.
*
* This file is part of ffxivbis
* (see https://github.com/arcan1s/ffxivbis).

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2021-2026 Evgeniy Alekseev.
* Copyright (c) 2019-2022 Evgeniy Alekseev.
*
* This file is part of ffxivbis
* (see https://github.com/arcan1s/ffxivbis).

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2021-2026 Evgeniy Alekseev.
* Copyright (c) 2019-2022 Evgeniy Alekseev.
*
* This file is part of ffxivbis
* (see https://github.com/arcan1s/ffxivbis).

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2021-2026 Evgeniy Alekseev.
* Copyright (c) 2019-2022 Evgeniy Alekseev.
*
* This file is part of ffxivbis
* (see https://github.com/arcan1s/ffxivbis).

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2021-2026 Evgeniy Alekseev.
* Copyright (c) 2019-2022 Evgeniy Alekseev.
*
* This file is part of ffxivbis
* (see https://github.com/arcan1s/ffxivbis).

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2021-2026 Evgeniy Alekseev.
* Copyright (c) 2019-2022 Evgeniy Alekseev.
*
* This file is part of ffxivbis
* (see https://github.com/arcan1s/ffxivbis).

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2021-2026 Evgeniy Alekseev.
* Copyright (c) 2019-2022 Evgeniy Alekseev.
*
* This file is part of ffxivbis
* (see https://github.com/arcan1s/ffxivbis).
@ -10,9 +10,9 @@ package me.arcanis.ffxivbis.service
import me.arcanis.ffxivbis.models.{Piece, Player, PlayerIdWithCounters}
class LootSelector(players: Seq[Player], pieces: Seq[Piece], orderBy: Seq[String]) {
class LootSelector(players: Seq[Player], piece: Piece, orderBy: Seq[String]) {
val counters: Seq[PlayerIdWithCounters] = pieces.flatMap(piece => players.map(_.withCounters(Some(piece))))
val counters: Seq[PlayerIdWithCounters] = players.map(_.withCounters(Some(piece)))
def suggest: LootSelector.LootSelectorResult =
LootSelector.LootSelectorResult {
@ -22,8 +22,8 @@ class LootSelector(players: Seq[Player], pieces: Seq[Piece], orderBy: Seq[String
object LootSelector {
def apply(players: Seq[Player], pieces: Seq[Piece], orderBy: Seq[String]): LootSelectorResult =
new LootSelector(players, pieces, orderBy).suggest
def apply(players: Seq[Player], piece: Piece, orderBy: Seq[String]): LootSelectorResult =
new LootSelector(players, piece, orderBy).suggest
case class LootSelectorResult(result: Seq[PlayerIdWithCounters])
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2021-2026 Evgeniy Alekseev.
* Copyright (c) 2019-2022 Evgeniy Alekseev.
*
* This file is part of ffxivbis
* (see https://github.com/arcan1s/ffxivbis).

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2021-2026 Evgeniy Alekseev.
* Copyright (c) 2019-2022 Evgeniy Alekseev.
*
* This file is part of ffxivbis
* (see https://github.com/arcan1s/ffxivbis).
@ -50,7 +50,7 @@ class BisProvider(context: ActorContext[BiSProviderMessage])
private def get(link: String, job: Job): Future[Seq[Piece]] =
try {
val url = Uri(link)
val id = Paths.get(link).normalize.getFileName.toString
val id = Paths.get(link).normalize.getFileName.toString
val parser =
if (url.authority.host.address().contains("etro")) Etro
@ -90,5 +90,6 @@ object BisProvider {
case "ringleft" | "fingerl" => "left ring"
case "ringright" | "fingerr" => "right ring"
case "weapon" | "head" | "body" | "hand" | "hands" | "legs" | "feet" | "ears" | "neck" | "wrist" | "wrists" => key
case "hand" => "hands"
}
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2021-2026 Evgeniy Alekseev.
* Copyright (c) 2019-2022 Evgeniy Alekseev.
*
* This file is part of ffxivbis
* (see https://github.com/arcan1s/ffxivbis).

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2021-2026 Evgeniy Alekseev.
* Copyright (c) 2019-2022 Evgeniy Alekseev.
*
* This file is part of ffxivbis
* (see https://github.com/arcan1s/ffxivbis).
@ -15,6 +15,7 @@ import spray.json._
import scala.concurrent.{ExecutionContext, Future}
import scala.jdk.CollectionConverters._
import scala.util.Try
import scala.util.matching.Regex
trait XivApi extends RequestExecutor {
@ -40,39 +41,106 @@ trait XivApi extends RequestExecutor {
else remotePieceType(remote).map(_ ++ local)
}
private def remotePieceType(itemIds: Seq[Long]): Future[Map[Long, PieceType]] =
Future
.traverse(itemIds) { id =>
val uriForItem = Uri(xivapiUrl)
.withPath(Uri.Path / "api" / "sheet" / "Item" / id.toString)
.withQuery(
Uri.Query(
Map(
"fields" -> Seq("Lot").mkString(","),
"private_key" -> xivapiKey.getOrElse("")
)
private def remotePieceType(itemIds: Seq[Long]): Future[Map[Long, PieceType]] = {
val uriForItems = Uri(xivapiUrl)
.withPath(Uri.Path / "item")
.withQuery(
Uri.Query(
Map(
"columns" -> Seq("ID", "GameContentLinks").mkString(","),
"ids" -> itemIds.mkString(","),
"private_key" -> xivapiKey.getOrElse("")
)
)
)
sendRequest(uriForItems, XivApi.parseXivapiJsonToShop).flatMap { shops =>
val shopIds = shops.values.map(_._2).toSet
val columns = shops.values.map(pair => s"ItemCost${pair._1}").toSet
val uriForShops = Uri(xivapiUrl)
.withPath(Uri.Path / "specialshop")
.withQuery(
Uri.Query(
Map(
"columns" -> (columns + "ID").mkString(","),
"ids" -> shopIds.mkString(","),
"private_key" -> xivapiKey.getOrElse("")
)
)
)
sendRequest(uriForItem, XivApi.parseXivapiJsonToLot).map(id -> _)
}
.map(_.toMap)
sendRequest(uriForShops, XivApi.parseXivapiJsonToType(shops))
}
}
}
object XivApi {
private def parseXivapiJsonToLot(js: JsObject)(implicit executionContext: ExecutionContext): Future[PieceType] =
private val defaultShop = JsObject("IsUnique" -> JsNumber(1), "StackSize" -> JsNumber(999))
private val itemRegexp = new Regex("""Item(Receive|Cost)(\d+)""", "type", "index")
private def parseXivapiJsonToShop(
js: JsObject
)(implicit executionContext: ExecutionContext): Future[Map[Long, (String, Long)]] = {
def extractTraderId(js: JsObject) =
js.fields
.get("Recipe")
.map(_ => "crafted" -> -1L) // you can craft this item
.orElse { // lets try shop items
js.fields("SpecialShop").asJsObject.fields.collectFirst {
case (shopName, JsArray(array)) if itemRegexp.matches(shopName) =>
val shopId = array.head match {
case JsNumber(id) => id.toLong
case other => throw deserializationError(s"Could not parse $other")
}
itemRegexp.findFirstMatchIn(shopName).get.group("index") -> shopId
}
}
.getOrElse(throw deserializationError(s"Could not parse $js"))
Future {
js.fields("fields") match {
case JsObject(fields) =>
fields
.get("Lot")
.collect {
case JsBoolean(true) => PieceType.Savage
case JsBoolean(false) => PieceType.Tome
js.fields("Results") match {
case array: JsArray =>
array.elements
.map(_.asJsObject.getFields("ID", "GameContentLinks") match {
case Seq(JsNumber(id), shop: JsObject) => id.toLong -> extractTraderId(shop.asJsObject)
case other => throw deserializationError(s"Could not parse $other")
})
.toMap
case other => throw deserializationError(s"Could not parse $other")
}
}
}
private def parseXivapiJsonToType(
shops: Map[Long, (String, Long)]
)(js: JsObject)(implicit executionContext: ExecutionContext): Future[Map[Long, PieceType]] =
Future {
val shopMap = js.fields("Results") match {
case array: JsArray =>
array.elements.collect { case shop: JsObject =>
shop.fields("ID") match {
case JsNumber(id) => id.toLong -> shop
case other => throw deserializationError(s"Could not parse $other")
}
.getOrElse(throw deserializationError(s"Could not find lot field in $fields"))
case other => throw deserializationError(s"Could not read fields as object from $other")
}.toMap
case other => throw deserializationError(s"Could not parse $other")
}
shops.map { case (itemId, (index, shopId)) =>
val pieceType =
if (index == "crafted" && shopId == -1L) PieceType.Crafted
else
Try(shopMap(shopId).fields(s"ItemCost$index").asJsObject)
.getOrElse(defaultShop)
.getFields("IsUnique", "StackSize") match {
case Seq(JsNumber(isUnique), JsNumber(stackSize)) =>
if (isUnique == 1 || stackSize.toLong != 999) PieceType.Tome // either upgraded gear or tomes found
else PieceType.Savage
case other => throw deserializationError(s"Could not parse $other")
}
itemId -> pieceType
}
}
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2021-2026 Evgeniy Alekseev.
* Copyright (c) 2019-2022 Evgeniy Alekseev.
*
* This file is part of ffxivbis
* (see https://github.com/arcan1s/ffxivbis).

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2021-2026 Evgeniy Alekseev.
* Copyright (c) 2019-2022 Evgeniy Alekseev.
*
* This file is part of ffxivbis
* (see https://github.com/arcan1s/ffxivbis).

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2021-2026 Evgeniy Alekseev.
* Copyright (c) 2019-2022 Evgeniy Alekseev.
*
* This file is part of ffxivbis
* (see https://github.com/arcan1s/ffxivbis).

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2021-2026 Evgeniy Alekseev.
* Copyright (c) 2019-2022 Evgeniy Alekseev.
*
* This file is part of ffxivbis
* (see https://github.com/arcan1s/ffxivbis).

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2021-2026 Evgeniy Alekseev.
* Copyright (c) 2019-2022 Evgeniy Alekseev.
*
* This file is part of ffxivbis
* (see https://github.com/arcan1s/ffxivbis).

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2021-2026 Evgeniy Alekseev.
* Copyright (c) 2019-2022 Evgeniy Alekseev.
*
* This file is part of ffxivbis
* (see https://github.com/arcan1s/ffxivbis).

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2021-2026 Evgeniy Alekseev.
* Copyright (c) 2019-2022 Evgeniy Alekseev.
*
* This file is part of ffxivbis
* (see https://github.com/arcan1s/ffxivbis).

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2021-2026 Evgeniy Alekseev.
* Copyright (c) 2019-2022 Evgeniy Alekseev.
*
* This file is part of ffxivbis
* (see https://github.com/arcan1s/ffxivbis).

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2021-2026 Evgeniy Alekseev.
* Copyright (c) 2019-2022 Evgeniy Alekseev.
*
* This file is part of ffxivbis
* (see https://github.com/arcan1s/ffxivbis).
@ -40,14 +40,7 @@ trait DatabaseLootHandler { this: Database =>
case SuggestLoot(partyId, piece, client) =>
run {
getParty(partyId, withBiS = true, withLoot = true)
.map(_.suggestLoot(Seq(piece)))
}(client ! _)
Behaviors.same
case SuggestMultiLoot(partyId, pieces, client) =>
run {
getParty(partyId, withBiS = true, withLoot = true)
.map(_.suggestLoot(pieces))
.map(_.suggestLoot(piece))
}(client ! _)
Behaviors.same
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2021-2026 Evgeniy Alekseev.
* Copyright (c) 2019-2022 Evgeniy Alekseev.
*
* This file is part of ffxivbis
* (see https://github.com/arcan1s/ffxivbis).

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2021-2026 Evgeniy Alekseev.
* Copyright (c) 2019-2022 Evgeniy Alekseev.
*
* This file is part of ffxivbis
* (see https://github.com/arcan1s/ffxivbis).

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2021-2026 Evgeniy Alekseev.
* Copyright (c) 2019-2022 Evgeniy Alekseev.
*
* This file is part of ffxivbis
* (see https://github.com/arcan1s/ffxivbis).

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2021-2026 Evgeniy Alekseev.
* Copyright (c) 2019-2022 Evgeniy Alekseev.
*
* This file is part of ffxivbis
* (see https://github.com/arcan1s/ffxivbis).

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2021-2026 Evgeniy Alekseev.
* Copyright (c) 2019-2022 Evgeniy Alekseev.
*
* This file is part of ffxivbis
* (see https://github.com/arcan1s/ffxivbis).

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2021-2026 Evgeniy Alekseev.
* Copyright (c) 2019-2022 Evgeniy Alekseev.
*
* This file is part of ffxivbis
* (see https://github.com/arcan1s/ffxivbis).

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2021-2026 Evgeniy Alekseev.
* Copyright (c) 2019-2022 Evgeniy Alekseev.
*
* This file is part of ffxivbis
* (see https://github.com/arcan1s/ffxivbis).

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2021-2026 Evgeniy Alekseev.
* Copyright (c) 2019-2022 Evgeniy Alekseev.
*
* This file is part of ffxivbis
* (see https://github.com/arcan1s/ffxivbis).

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2021-2026 Evgeniy Alekseev.
* Copyright (c) 2019-2022 Evgeniy Alekseev.
*
* This file is part of ffxivbis
* (see https://github.com/arcan1s/ffxivbis).

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2021-2026 Evgeniy Alekseev.
* Copyright (c) 2019-2022 Evgeniy Alekseev.
*
* This file is part of ffxivbis
* (see https://github.com/arcan1s/ffxivbis).

View File

@ -67,21 +67,6 @@ object Fixtures {
Piece.Ring(pieceType = PieceType.Tome, Job.VPR, "right ring")
)
)
lazy val bis5: BiS = BiS(
Seq(
Piece.Weapon(pieceType = PieceType.Savage ,Job.BRD),
Piece.Head(pieceType = PieceType.Tome, Job.BRD),
Piece.Body(pieceType = PieceType.Savage, Job.BRD),
Piece.Hands(pieceType = PieceType.Savage, Job.BRD),
Piece.Legs(pieceType = PieceType.Tome, Job.BRD),
Piece.Feet(pieceType = PieceType.Tome, Job.BRD),
Piece.Ears(pieceType = PieceType.Tome, Job.BRD),
Piece.Neck(pieceType = PieceType.Savage, Job.BRD),
Piece.Wrist(pieceType = PieceType.Tome, Job.BRD),
Piece.Ring(pieceType = PieceType.Tome, Job.BRD, "left ring"),
Piece.Ring(pieceType = PieceType.Savage, Job.BRD, "right ring")
)
)
lazy val link: String = "https://ffxiv.ariyala.com/19V5R"
lazy val link2: String = "https://ffxiv.ariyala.com/1A0WM"
@ -89,7 +74,6 @@ object Fixtures {
lazy val link4: String = "https://etro.gg/gearset/865fc886-994f-4c28-8fc1-4379f160a916"
lazy val link5: String = "https://ffxiv.ariyala.com/1FGU0"
lazy val link6: String = "https://xivgear.app/?page=sl%7Cd65b4776-01e1-4269-af74-0bc6e01ca2ec"
lazy val link7: String = "https://xivgear.app/?page=sl|22777835-b7c8-457e-bf21-6221d0d122ea"
lazy val lootWeapon: Piece = Piece.Weapon(pieceType = PieceType.Tome, Job.AnyJob)
lazy val lootBody: Piece = Piece.Body(pieceType = PieceType.Savage, Job.AnyJob)

View File

@ -43,14 +43,14 @@ class LootSelectorTest extends AnyWordSpecLike with Matchers with BeforeAndAfter
"loot selector" must {
"suggest loot by isRequired" in {
toPlayerId(default.suggestLoot(Seq(Piece.Head(pieceType = PieceType.Savage, Job.AnyJob)))) shouldEqual Seq(dnc.playerId, drg.playerId)
toPlayerId(default.suggestLoot(Piece.Head(pieceType = PieceType.Savage, Job.AnyJob))) shouldEqual Seq(dnc.playerId, drg.playerId)
}
"suggest loot if a player already have it" in {
val piece = Piece.Body(pieceType = PieceType.Savage, Job.AnyJob)
val party = default.withPlayer(dnc.withLoot(piece))
toPlayerId(party.suggestLoot(Seq(piece))) shouldEqual Seq(drg.playerId, dnc.playerId)
toPlayerId(party.suggestLoot(piece)) shouldEqual Seq(drg.playerId, dnc.playerId)
}
"suggest upgrade" in {
@ -60,26 +60,26 @@ class LootSelectorTest extends AnyWordSpecLike with Matchers with BeforeAndAfter
)
)
toPlayerId(party.suggestLoot(Seq(Piece.WeaponUpgrade))) shouldEqual Seq(dnc.playerId, drg.playerId)
toPlayerId(party.suggestLoot(Piece.WeaponUpgrade)) shouldEqual Seq(dnc.playerId, drg.playerId)
}
"suggest loot by priority" in {
val party = default.withPlayer(dnc.copy(priority = 2))
toPlayerId(party.suggestLoot(Seq(Piece.Body(pieceType = PieceType.Savage, Job.AnyJob)))) shouldEqual Seq(drg.playerId, dnc.playerId)
toPlayerId(party.suggestLoot(Piece.Body(pieceType = PieceType.Savage, Job.AnyJob))) shouldEqual Seq(drg.playerId, dnc.playerId)
}
"suggest loot by bis pieces got" in {
val party = default.withPlayer(dnc.withLoot(Piece.Head(pieceType = PieceType.Savage, Job.AnyJob)))
toPlayerId(party.suggestLoot(Seq(Piece.Body(pieceType = PieceType.Savage, Job.AnyJob)))) shouldEqual Seq(drg.playerId, dnc.playerId)
toPlayerId(party.suggestLoot(Piece.Body(pieceType = PieceType.Savage, Job.AnyJob))) shouldEqual Seq(drg.playerId, dnc.playerId)
}
"suggest loot by this piece got" in {
val piece = Piece.Body(pieceType = PieceType.Tome, Job.AnyJob)
val party = default.withPlayer(dnc.withLoot(piece))
toPlayerId(party.suggestLoot(Seq(piece))) shouldEqual Seq(drg.playerId, dnc.playerId)
toPlayerId(party.suggestLoot(piece)) shouldEqual Seq(drg.playerId, dnc.playerId)
}
"suggest loot by total piece got" in {
@ -88,7 +88,7 @@ class LootSelectorTest extends AnyWordSpecLike with Matchers with BeforeAndAfter
.withPlayer(dnc.withLoot(Seq(piece, piece).map(pieceToLoot)))
.withPlayer(drg.withLoot(piece))
toPlayerId(party.suggestLoot(Seq(piece))) shouldEqual Seq(drg.playerId, dnc.playerId)
toPlayerId(party.suggestLoot(piece)) shouldEqual Seq(drg.playerId, dnc.playerId)
}
}

View File

@ -35,7 +35,7 @@ class BisProviderTest extends ScalaTestWithActorTestKit(Settings.withRandomDatab
probe.expectMessage(askTimeout, Fixtures.bis)
}
"get best in slot set (etro 2)" ignore {
"get best in slot set (etro 2)" in {
val probe = testKit.createTestProbe[BiS]()
provider ! DownloadBiS(Fixtures.link4, Job.DNC, probe.ref)
probe.expectMessage(askTimeout, Fixtures.bis2)
@ -47,11 +47,5 @@ class BisProviderTest extends ScalaTestWithActorTestKit(Settings.withRandomDatab
probe.expectMessage(askTimeout, Fixtures.bis4)
}
"get best in slot set (xivgear 2)" in {
val probe = testKit.createTestProbe[BiS]()
provider ! DownloadBiS(Fixtures.link7, Job.BRD, probe.ref)
probe.expectMessage(askTimeout, Fixtures.bis5)
}
}
}

View File

@ -1 +1 @@
version := "0.15.7"
version := "0.15.2"