Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build and Push #34

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 33 additions & 6 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,45 @@ on:
branches:
- main

env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}

jobs:
build:
runs-on: ubuntu-latest

permissions:
contents: read
packages: write
attestations: write
id-token: write
steps:
- name: Checkout code
uses: actions/checkout@v3

uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: '^1.22'

go-version: '^1.23'
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
- name: Run tests
run: go test -v ./...
run: go test -v ./...
- name: Build and push Docker image
id: push
uses: docker/build-push-action@v6
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
10 changes: 6 additions & 4 deletions internal/models/character.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ import (
"github.com/promiseofcake/artifactsmmo-engine/internal/math"
)

const maxLevel = 40

// Character is our representation of the Player's character
// Ideally we can update this state with the value of a response
// from a request.
Expand Down Expand Up @@ -38,22 +40,22 @@ func (c Character) ChooseWeakestSkill() CharacterSkill {
{
Code: client.ResourceSchemaSkillWoodcutting,
CurrentLevel: c.WoodcuttingLevel,
MinLevel: map[bool]int{true: 20, false: math.Max(0, c.WoodcuttingLevel-10)}[c.WoodcuttingLevel == 35],
MinLevel: map[bool]int{true: 20, false: math.Max(0, c.WoodcuttingLevel-10)}[c.WoodcuttingLevel == maxLevel],
},
{
Code: client.ResourceSchemaSkillMining,
CurrentLevel: c.MiningLevel,
MinLevel: map[bool]int{true: 20, false: math.Max(0, c.MiningLevel-10)}[c.MiningLevel == 35],
MinLevel: map[bool]int{true: 20, false: math.Max(0, c.MiningLevel-10)}[c.MiningLevel == maxLevel],
},
{
Code: client.ResourceSchemaSkillFishing,
CurrentLevel: c.FishingLevel,
MinLevel: map[bool]int{true: 20, false: math.Max(0, c.FishingLevel-10)}[c.FishingLevel == 35],
MinLevel: map[bool]int{true: 20, false: math.Max(0, c.FishingLevel-10)}[c.FishingLevel == maxLevel],
},
}

// if maxed out, do mining
if c.FishingLevel == 35 && c.MiningLevel == 35 && c.WoodcuttingLevel == 35 {
if c.FishingLevel == maxLevel && c.MiningLevel == maxLevel && c.WoodcuttingLevel == maxLevel {
return skills[1]
}

Expand Down
Loading