Skip to content

Commit

Permalink
added auction feature buy and updated help section
Browse files Browse the repository at this point in the history
  • Loading branch information
Soapalin authored May 20, 2024
1 parent 5e62c39 commit cced940
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 6 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,12 @@ Current version: v0.0.1
- [x] Create a release page for pre-built .exe

### Road to v0.2
- [] Auction feature with higher price
- [x] Auction feature with higher price
- [x] Search Book function in Auction
- [] Search Book function in My Bookshelf
- [] Delete debug.log after several days or when it reaches a certain size
- [] Update Help View
- [] Add a way to display whether item has already been purchased or not in Bookshop
- [x] Update Help View
- [x] Add a way to display whether item has already been purchased or not in Bookshop

### Road to v0.3
- [] Add item effects
Expand Down
10 changes: 7 additions & 3 deletions auction_view.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,15 @@ import (
"fmt"
"game/engine/theme"
"log"
"math/rand"
"strconv"
"strings"

"github.com/charmbracelet/lipgloss"
)

var AUCTION_COST_MODIFIER int = 2

func (m *DashboardModel) AuctionView() string {
s := ""
s += theme.Heading1.Render("Auction") + "\n"
Expand Down Expand Up @@ -47,7 +50,7 @@ func (m *DashboardModel) AuctionView() string {
}
currentLine = append(currentLine, textStyle.Width(m.width/2).Render(b.Name+", "+b.Author))
currentLine = append(currentLine, textStyle.Width(m.width/8).Render(strconv.Itoa(b.IntelligenceRequirement)))
currentLine = append(currentLine, textStyle.Width(m.width/4).Render(strconv.Itoa(b.KnowledgeRequirement)))
currentLine = append(currentLine, textStyle.Width(m.width/4).Render(strconv.Itoa(b.KnowledgeRequirement*AUCTION_COST_MODIFIER)))
if m.ps.Reader.Library.ContainsBook(b) {
currentLine = append(currentLine, textStyle.Width(m.width/8).Render(RenderEmojiOrFallback("✅", []string{"Yes"})))
} else {
Expand Down Expand Up @@ -146,6 +149,7 @@ func (m *DashboardModel) SubmitAuctionSearch() {
m.auctionLibrary = lib
m.auctionPaginator.SetTotalPages(len(m.auctionLibrary.Books))
m.auctionPaginator.Page = 0
AUCTION_COST_MODIFIER = rand.Intn(5) + 2

}

Expand All @@ -155,10 +159,10 @@ func (m *DashboardModel) AuctionBuy() TransactionResult {
if book.IntelligenceRequirement > m.ps.Reader.IQ {
return iqMissingTransaction
}
if book.KnowledgeRequirement > m.ps.Reader.Knowledge {
if (book.KnowledgeRequirement * AUCTION_COST_MODIFIER) > m.ps.Reader.Knowledge {
return knowledgeMissingTransaction
}
m.ps.Reader.DecreaseKnowledge(book.KnowledgeRequirement)
m.ps.Reader.DecreaseKnowledge(book.KnowledgeRequirement * AUCTION_COST_MODIFIER)
m.ps.Reader.Library.AddBookToLibrary(book)
return bookTransaction
}
Expand Down
5 changes: 5 additions & 0 deletions dashboard.go
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,11 @@ func (m *DashboardModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
switched := InitialSaveMenuModel()
return InitialRootModel().SwitchScreen(&switched)
}
case "b":
switch m.activeTab {
case 3:
m.TryAuctionBuy()
}
case tea.KeyCtrlX.String():
switch m.activeTab {
case 3:
Expand Down
3 changes: 3 additions & 0 deletions help_view.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ func (h *HelpItem) View(maxWidth int) string {

var HelpSection []HelpItem = []HelpItem{
{"How do I play this game?", "Purchase, Read, Gain Knowlege and IQ, and finally collect your favourite books!"},
{"How do I purchcase books?", "Purchase your books in the Bookshop or Auction. Bookshop books are refreshed and totally randomised while you can look for your favourtie book in the Auction window. Beware, prices are higher!"},
{"How do I increase my IQ?", "IQ only increases by a small amount on your first read! You will need to purchase and read different books in order to increase it."},
{"How do I read the book I have purchased?", "Head to the your Bookshelf and press 'r' on the book you would like to read."},
{"Where can I find an in-depth game guide?", "Head to our official wiki," + lipgloss.NewStyle().Foreground(theme.Pink).Render("{https://placeholder.com}")},
}

Expand Down

0 comments on commit cced940

Please sign in to comment.