Market: Add duration indicator
This commit is contained in:
parent
3ab7b0969e
commit
59746711e1
1 changed files with 13 additions and 2 deletions
15
main.go
15
main.go
|
@ -638,7 +638,7 @@ func printCharacterMarketOrders(swaggerclient *ESI.App, m *Character) string {
|
||||||
|
|
||||||
maxWidth, _ := terminal.Width()
|
maxWidth, _ := terminal.Width()
|
||||||
// We need to add the length of the colors
|
// We need to add the length of the colors
|
||||||
maxWidth = maxWidth + uint(len(fmt.Sprint(aurora.Red("")))*2)
|
maxWidth = maxWidth + uint(len(fmt.Sprint(aurora.Red("")))*3)
|
||||||
|
|
||||||
lineFormat := fmt.Sprintf("%%.%ds\n", maxWidth)
|
lineFormat := fmt.Sprintf("%%.%ds\n", maxWidth)
|
||||||
|
|
||||||
|
@ -662,6 +662,16 @@ func printCharacterMarketOrders(swaggerclient *ESI.App, m *Character) string {
|
||||||
status = fmt.Sprint(aurora.Green(buySellStatus).Bold())
|
status = fmt.Sprint(aurora.Green(buySellStatus).Bold())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
duration := fmt.Sprintf("%d/%d", remainingDuration/time.Hour/24, *order.Duration)
|
||||||
|
pctDaysRemaining := float32(remainingDuration/time.Hour/24) / float32(*order.Duration)
|
||||||
|
if pctDaysRemaining <= 0.25 {
|
||||||
|
duration = fmt.Sprint(aurora.Red(duration))
|
||||||
|
} else if pctDaysRemaining <= 0.5 {
|
||||||
|
duration = fmt.Sprint(aurora.Brown(duration))
|
||||||
|
} else {
|
||||||
|
duration = fmt.Sprint(aurora.Green(duration))
|
||||||
|
}
|
||||||
|
|
||||||
quantity := fmt.Sprintf("%d/%d", *order.VolumeRemain, *order.VolumeTotal)
|
quantity := fmt.Sprintf("%d/%d", *order.VolumeRemain, *order.VolumeTotal)
|
||||||
pctRemaining := float32(*order.VolumeRemain) / float32(*order.VolumeTotal)
|
pctRemaining := float32(*order.VolumeRemain) / float32(*order.VolumeTotal)
|
||||||
if pctRemaining <= 0.25 {
|
if pctRemaining <= 0.25 {
|
||||||
|
@ -678,12 +688,13 @@ func printCharacterMarketOrders(swaggerclient *ESI.App, m *Character) string {
|
||||||
log.Fatalf("Got error on getStructureStationInfo: %T %s", sErr, sErr)
|
log.Fatalf("Got error on getStructureStationInfo: %T %s", sErr, sErr)
|
||||||
}
|
}
|
||||||
|
|
||||||
line := fmt.Sprintf(" %s % 25.25s ISK % 12s ISK % 13s (%s) %s",
|
line := fmt.Sprintf(" %s % 25.25s ISK % 12s ISK % 13s (%s) (%s) %s",
|
||||||
status,
|
status,
|
||||||
pinNames[*order.TypeID],
|
pinNames[*order.TypeID],
|
||||||
ac.FormatMoney(*order.Price),
|
ac.FormatMoney(*order.Price),
|
||||||
ac.FormatMoney(remainingAmount),
|
ac.FormatMoney(remainingAmount),
|
||||||
quantity,
|
quantity,
|
||||||
|
duration,
|
||||||
sInfo.Name,
|
sInfo.Name,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
Reference in a new issue