Skip to content

Commit

Permalink
rework modinfo
Browse files Browse the repository at this point in the history
  • Loading branch information
froehlichA committed Apr 17, 2022
1 parent 175a061 commit b956fab
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
10 changes: 5 additions & 5 deletions src/modpack/modinfo.nim
Expand Up @@ -4,10 +4,10 @@
## - if the addon is up-to-date
## - if the addon is compatible with the modpack

import sequtils, sugar
import std/[sequtils, sugar]
import ../api/cfcore
import ../term/color
import ../modpack/version
import ../term/color

type
Compability* = enum
Expand Down Expand Up @@ -50,14 +50,14 @@ proc getMessage*(c: Compability): string =
of Compability.Major: "The installed mod only matches the major version as the modpack. Issues may arise."
of Compability.None: "The installed mod is incompatible with the modpack's minecraft version."

proc getFreshness*(file: CfAddonFile, modpackVersion: Version, addon: CfAddon): Freshness =
proc getFreshness*(file: CfAddonFile, mpVersion: Version, addon: CfAddon): Freshness =
## get freshness of a file
let latestFiles = addon.gameVersionLatestFiles
let modpackVersionFiles = latestFiles.filter((x) => x.version == modpackVersion)
let modpackVersionFiles = latestFiles.filter((x) => x.version == mpVersion)
if modpackVersionFiles.len == 1:
if modpackVersionFiles[0].fileId == file.fileId:
return Freshness.Newest
if latestFiles.any((x) => x.fileId == file.fileId and x.version.minor == modpackVersion.minor):
if latestFiles.any((x) => x.fileId == file.fileId and x.version.minor == mpVersion.minor):
return Freshness.NewestForAVersion
return Freshness.Old

Expand Down
5 changes: 3 additions & 2 deletions tests/modpack/tmodinfo.nim
@@ -1,5 +1,6 @@
import sequtils, sugar
import api/cfcore, modpack/modinfo, modpack/version
import std/[sequtils, sugar]
import api/cfcore
import modpack/[modinfo, version]

proc initCfAddon(projectId: int, name: string, gameVersionLatestFiles: seq[tuple[version: Version, fileId: int]]): CfAddon =
result = CfAddon()
Expand Down

0 comments on commit b956fab

Please sign in to comment.