working buytoken (untested)

This commit is contained in:
peter
2020-02-08 13:54:14 +01:00
parent 6930e2245f
commit 59f518679e
37 changed files with 348 additions and 223 deletions
@@ -10,9 +10,12 @@ import { ShoutMessage } from '../../../../../../backend/Components/Shoutbox/Inte
[type]="text"
[message]="msg.message"
[sender]="msg.sender"
[date]="msg.date">
[date]="msg.date"
[reply]="msg.reply">
</nb-chat-message>
<nb-chat-form (send)="submit($event)" [dropFiles]="false">
<nb-chat-form
(send)="submit($event)"
[dropFiles]="false">
</nb-chat-form>
</nb-chat>
`,
@@ -25,13 +25,7 @@ status="control">
<br/><br />
<span *ngFor="let token of tokens">
[ {{token.level}} ]
<a [ngStyle]="{'color':token.quality=='Epic'?'#a335ee':'#ff8000'}"
target="_blank"
[href]="token.url">
<img style="min-width: 25px; width: 2.25vw; max-width: 50px"
[src]="'https://wow.zamimg.com/images/wow/icons/large/'+token.iconname+'.jpg'" />
{{token.itemname}}
</a><br />
<wowhead [item]="token"></wowhead><br />
</span>
</nb-card-body>
</nb-card>
@@ -3,6 +3,7 @@ import { ActivatedRoute, Router } from '@angular/router';
import { ApiService as ApiService } from '../../services/login-api';
import { Spec, User, Character } from '../../../../../../backend/Types/Types';
import { getClassColor } from '../../../../../../backend/Types/PlayerSpecs';
import { _Tiers } from '../../../../../../backend/Types/Items';
@Component({
selector: 'character',
@@ -35,7 +36,7 @@ export class FrontcraftCharacterComponent implements OnInit{
if(char){
this.color = getClassColor(char.class)
this.char = char
this.api.get('ItemManager').getTokens(this.char).then(tokens => {
this.api.get('ItemManager').getTokens(this.char, _Tiers, true).then(tokens => {
this.tokens = tokens
})
}
@@ -38,6 +38,8 @@ import { FrontcraftItemSelectComponent } from './shop/itemselector.component';
import { NgxEchartsModule } from 'ngx-echarts';
import { FrontcraftCharactersComponent } from './characters/characters.component';
import { FrontcraftBuyTokenComponent } from './shop/buytoken.component';
import { FrontcraftItemComponent } from './shop/item.component';
import { FrontcraftWowheadComponent } from './shop/wowhead.component';
@NgModule({
@@ -81,6 +83,8 @@ import { FrontcraftBuyTokenComponent } from './shop/buytoken.component';
FrontcraftRulesComponent,
FrontcraftCreateRaidsComponent,
FrontcraftBuyTokenComponent,
FrontcraftWowheadComponent,
FrontcraftItemComponent
],
entryComponents: [
FrontcraftItemSelectComponent,
@@ -13,6 +13,7 @@ export class FrontcraftArchiveComponent implements OnInit{
canSignup = false
isSignedup = false
canManage = false
isTier = false
mySignup
raid: RaidData = <any>{
@@ -2,7 +2,10 @@
<nb-card-body>
<nb-tabset>
<nb-tab tabTitle="Info">
<h1>{{raid.title}}</h1>
<h1>
<img [src]="'../../../../assets/images/'+(raid.tier || 'null').toLowerCase()+'.png'" style="height: 100px" />
{{raid.title}}
</h1>
<p>
{{raid.signupcount}} / {{raid.size}} signups
</p>
@@ -167,10 +170,10 @@
</ng-container>
</div>
</nb-tab>
<nb-tab tabTitle="Shop" *ngIf="isSignedup">
<shop (onSelect)="itemSelect($event)"></shop>
<nb-tab tabTitle="Items" *ngIf="isSignedup && isTier">
<shop [tier]="raid.tier" (onSelect)="itemSelect($event)"></shop>
</nb-tab>
<nb-tab tabTitle="Reserves">
<nb-tab tabTitle="Reserves" *ngIf="isTier">
<input type="text" nbInput [(ngModel)]="search" (change)="changeSearch()" placeholder="Search" fullWidth="true">
<nb-list>
@@ -6,6 +6,7 @@ import { NbWindowService, NbToastrService, NbDialogService } from '@nebular/them
import { FrontcraftCharacerpickerComponent } from './characterpicker.component';
import { getClassColor, SpecT } from '../../../../../../backend/Types/PlayerSpecs';
import { FrontcraftBuyTokenComponent } from '../shop/buytoken.component';
import { allItems } from '../../../../../../backend/Types/Items';
@Component({
selector: 'raid',
@@ -16,6 +17,7 @@ export class FrontcraftRaidComponent implements OnInit{
canSignup = false
isSignedup = false
islate = false
isTier = false
manageRaid
mySignup: (Signup & Character & Spec)
@@ -33,7 +35,8 @@ export class FrontcraftRaidComponent implements OnInit{
},
tanks: [],
healers: [],
tokens:{}
tokens:{},
tier: 'MC'
}
tokens = {}
displayedtokens = {}
@@ -50,6 +53,7 @@ export class FrontcraftRaidComponent implements OnInit{
}
async ngOnInit(){
this.manageRaid = this.api.get('manageRaid')
const signupFeature = this.api.get('signup')
@@ -63,7 +67,9 @@ export class FrontcraftRaidComponent implements OnInit{
this.dialogService.open(FrontcraftBuyTokenComponent, {
context: {
item: item,
signup: this.mySignup
signup: this.mySignup,
tier: this.raid.tier,
characterName: this.mySignup.charactername
}
}).onClose.subscribe(() => this.refresh())
}
@@ -112,9 +118,6 @@ export class FrontcraftRaidComponent implements OnInit{
const signup = this.api.get('signup')
if(!signup) return
console.log("setlate");
await signup.sign(auth.token.value, {
...this.mySignup,
id: this.mySignup.characterid,
@@ -140,7 +143,8 @@ export class FrontcraftRaidComponent implements OnInit{
const raiddata = await raidManager.getRaidData(<any>{
id: param
})
this.isTier = allItems[raiddata.tier] != null
this.raid = raiddata
this.tokens = raiddata.tokens;
@@ -7,6 +7,10 @@
<nb-select [(selected)]="template" placeholder="copy from" (selectedChange)="onTemplateSelect()">
<nb-option *ngFor="let template of templates" [value]="template">{{template.title}} {{template.start| date : 'd MMMM'}}</nb-option>
</nb-select>
<nb-select [(selected)]="tier" placeholder="Tier" >
<nb-option *ngFor="let _tier of tiers" [value]="_tier">{{_tier}}</nb-option>
</nb-select>
<input type="text" nbInput [(ngModel)]="title" placeholder="Title" fullWidth="true">
<input type="number" nbInput [(ngModel)]="size" placeholder="size" fullWidth="true">
@@ -2,6 +2,7 @@ import { Component, OnInit } from '@angular/core';
import { ApiService } from '../../services/login-api';
import { Raid, RaidData } from '../../../../../../backend/Types/Types';
import { NbWindowRef, NbDialogRef } from '@nebular/theme';
import { Tiers, _Tiers } from '../../../../../../backend/Types/Items';
const ONE_MINUTE = 60000
const ONE_HOUR = 60 * ONE_MINUTE
@@ -21,6 +22,8 @@ export class FrontcraftCreateRaidsComponent implements OnInit {
minute = 0
size = 40
description = ""
tier: Tiers = null
tiers = _Tiers
constructor(
protected dialogRef: NbDialogRef<FrontcraftCreateRaidsComponent>,
@@ -37,6 +40,7 @@ export class FrontcraftCreateRaidsComponent implements OnInit {
this.minute = templateDate.getMinutes()
this.description = this.template.description
this.startdate = new Date(parseInt(this.template.start) - templateDate.getHours()*ONE_HOUR - templateDate.getMinutes()*ONE_MINUTE)
this.tier = this.template.tier
}
ngOnInit(){
@@ -49,6 +53,7 @@ export class FrontcraftCreateRaidsComponent implements OnInit {
size: this.size,
start: ""+new Date(this.startdate.getTime() + this.hour*ONE_HOUR + this.minute*ONE_MINUTE).getTime(),
title: this.title,
tier: this.tier
}
const manage = this.api.get('manageRaid')
if(!manage) return
@@ -17,7 +17,7 @@
style="cursor: pointer;">
<div class="row">
<div class="col-2">
<img src="../../../../assets/images/mage.png" style="height: 75px" />
<img [src]="'../../../../assets/images/'+(raid.tier || 'null').toLowerCase()+'.png'" style="height: 75px" />
</div>
<div class="col-2 vcenter">
@@ -7,15 +7,7 @@
<nb-tab tabTitle="priorities">
<nb-list>
<nb-list-item *ngFor="let item of rules | keyvalue">
<a [ngStyle]="{'color':item.value[0].quality=='Epic'?'#a335ee':'#ff8000'}"
target="_blank"
[href]="item.value[0].url">
<img style="min-width: 25px; width: 2.25vw; max-width: 50px"
[src]="'https://wow.zamimg.com/images/wow/icons/large/'+item.value[0].iconname+'.jpg'" />
&nbsp;
{{item.key}}
</a><br />
<wowhead [item]="item.value[0]"></wowhead><br>
<span *ngFor="let rule of item.value" [nbPopover]="templateRef" nbPopoverTrigger="hover">
<ng-template #templateRef>
<span style="color:white">{{rule.description}}</span>
@@ -15,49 +15,73 @@ import { _Tiers, allItems, Tiers } from '../../../../../../backend/Types/Items';
</nb-card-header>
<nb-card-body>
<p>
You currently have {{currency}} softreserve currency
{{currency}} softreserves remaining
</p>
<div *ngIf="currency>0">
<div *ngFor="let kv of modifier | keyvalue">
<nb-alert accent="danger" *ngIf="invalidatedTokens.length > 0">
Claiming this reserve invalidates the following streaks. <br />
This is not reversible.
<ul *ngFor="let item of invalidatedTokens">
<li>
[ {{item.level}} ]
<img style="min-width: 20px; width: 2.25vw; max-width: 35px" [src]="'https://wow.zamimg.com/images/wow/icons/large/'+item.iconname+'.jpg'" />
<span [ngStyle]="{'color':item.quality=='Epic'?'#a335ee':'#ff8000'}">
{{item.itemname}}
</span>
</li>
</ul>
</nb-alert>
<nb-alert accent="info" *ngIf="noToken">
The following reserve will be created<br />
<ul>
<li>
[ {{1+modifier}} ]
<img style="min-width: 20px; width: 2.25vw; max-width: 35px" [src]="'https://wow.zamimg.com/images/wow/icons/large/'+item.iconname+'.jpg'" />
<span [ngStyle]="{'color':item.quality=='Epic'?'#a335ee':'#ff8000'}">
{{item.itemname}}
</span>
<span *ngIf="modifier>0">(<b>+{{modifier}}</b> from priorities)</span>
</li>
</ul>
</nb-alert>
<nb-alert accent="info" *ngIf="upgradableToken != null">
The following reserve will be created<br />
<ul>
<li>
[ {{upgradableToken.level}} ] => [ {{upgradableToken.level+1}} ] <img style="min-width: 20px; width: 2.25vw; max-width: 35px" [src]="'https://wow.zamimg.com/images/wow/icons/large/'+upgradableToken.iconname+'.jpg'" />
<span [ngStyle]="{'color':upgradableToken.quality=='Epic'?'#a335ee':'#ff8000'}">{{upgradableToken.itemname}}</span>
</li>
</ul>
</nb-alert>
</div>
<button
(click)="buyToken(kv.key)"
[disabled]="currency<=0"
nbButton
outline
status="success"
size="tiny">
buy
(click)="buyToken()"
[disabled]="currency<=0"
nbButton
outline
status="success"
size="small">
<nb-icon icon="checkmark-outline"></nb-icon> claim
</button>
{{kv.key}} <span *ngIf="kv.value>0">(<b>+{{kv.value}}</b> from priorities)</span>
</div>
<div *ngFor="let token of ownedtokens">
<button
(click)="buyToken(token.charactername)"
nbButton
outline
status="success"
size="tiny">
buy
</button>
{{token.charactername}} [ {{token.level}} ] => [ {{token.level+1}} ]
</div>
</div>
</nb-card-body>
</nb-card>
`,
})
export class FrontcraftBuyTokenComponent implements OnInit{
@Input() characterName: string
@Input() item : Item
@Input() signup : Signup
@Input() tier: Tiers
characters: Character[]
modifier = {}
invalidatedTokens: (SRToken & Character & Item)[] | undefined = []
upgradableToken : (SRToken & Character & Item) | undefined
noToken = false
modifier
currency: number = 0
ownedtokens: SRToken[] = []
constructor(
private toastr: NbToastrService,
@@ -65,38 +89,36 @@ import { _Tiers, allItems, Tiers } from '../../../../../../backend/Types/Items';
private api : ApiService
){}
ngOnInit(): void {
async ngOnInit() {
const char = await this.api.get('CharacterManager').getCharacterByName(this.characterName)
if(!char) return
const passiveStreaks = await this.api.get('ItemManager').getTokens(char, [this.item.tier], false)
this.upgradableToken = passiveStreaks.find(p => p.itemname === this.item.itemname)
this.invalidatedTokens = passiveStreaks.filter(token => token.itemname !== this.item.itemname)
if(!this.upgradableToken)
this.upgradableToken = await this.api.get('ItemManager').getToken(char, this.item, true)
this.modifier = await this.api.get('ItemManager').calculatePriorities(this.item.itemname, char)
if(!this.upgradableToken) this.noToken = true
const usr = this.api.getCurrentUser()
this.api.get('CharacterManager')
.getCharactersOfUser(usr.username)
.then(chars => {
chars.forEach(char => {
chars.forEach(async char => {
char['color'] = getClassColor(char.class)
this.api.get('ItemManager').getToken(char, this.item, false).then(token => {
if(token) this.ownedtokens.push(token)
else{
this.api.get('ItemManager').getToken(char, this.item, true).then(tokken => {
if(tokken) this.ownedtokens.push(tokken)
else{
this.api.get('ItemManager').calculatePriorities(this.item.itemname, char).then(modifier => {
this.modifier[char.charactername] = modifier
})
}
})
}
})
})
this.characters = chars
})
this.api.get('UserManager').getUser(usr.username).then(u => {
if(!u) return
this.currency = u.currency
this.currency = u[this.tier] || 0
})
}
buyToken = async (charactername:string) => {
buyToken = async () => {
const src = this.api.get('ItemManager')
const token = await src.buyToken(this.api.getAuth().token.value, charactername, this.item.itemname, this.signup)
const token = await src.buyToken(this.api.getAuth().token.value, this.characterName, this.item.itemname, this.signup)
if(token){
this.toastr.show(token.charactername+' now has a token for '+token.itemname+' of level '+token.level, 'Yay', {status: 'success'})
@@ -0,0 +1,30 @@
import { Component, OnInit, ContentChild, AfterContentInit, ViewChild, AfterViewInit, Input, Output, EventEmitter } from '@angular/core';
import { ApiService as ApiService } from '../../services/login-api';
import { FrontcraftItemSelectComponent } from './itemselector.component';
import { NbWindowService, NbWindowRef, NbToastrService, NbDialogService, NbDialogRef } from '@nebular/theme';
import { Item, Character, SRToken, Signup } from '../../../../../../backend/Types/Types';
import { getClassColor } from '../../../../../../backend/Types/PlayerSpecs';
import { _Tiers, allItems, Tiers } from '../../../../../../backend/Types/Items';
@Component({
selector: 'item',
template: `
<span [ngStyle]="{'color':item.quality=='Epic'?'#a335ee':'#ff8000'}">
<img style="min-width: 20px; width: 2.25vw; max-width: 35px"
[src]="'https://wow.zamimg.com/images/wow/icons/large/'+item.iconname+'.jpg'" />
&nbsp;
{{item.itemname}}
</span>
`,
})
export class FrontcraftItemComponent implements OnInit{
@Input() item: Item
constructor(
private toastr: NbToastrService,
private api : ApiService
){}
async ngOnInit() {
}
}
@@ -14,13 +14,7 @@
select
</button>
&nbsp;
<a target="_blank" [href]="item.url">
<span [ngStyle]="{'color':item.quality=='Epic'?'#a335ee':'#ff8000'}">
<img style="min-width: 20px; width: 2.25vw; max-width: 35px"
[src]="'https://wow.zamimg.com/images/wow/icons/large/'+item.iconname+'.jpg'" />
&nbsp;
{{item.itemname}}
</span>
</a>
<wowhead [item]="item"></wowhead>
</nb-list-item>
</nb-list>
@@ -1,6 +1,6 @@
import { Component, OnInit, Input, Output, EventEmitter } from '@angular/core';
import { ApiService } from '../../services/login-api';
import { Item } from '../../../../../../backend/Types/Types';
import { Item, Character } from '../../../../../../backend/Types/Types';
@Component({
selector: 'itemselect',
@@ -13,6 +13,7 @@ export class FrontcraftItemSelectComponent implements OnInit{
allItems:Item[] = []
displayedItems: any[]
@Input() character: string
@Input() items: string[]
@Output() onSelect = new EventEmitter<Item>();
@@ -21,6 +22,7 @@ export class FrontcraftItemSelectComponent implements OnInit{
){}
async ngOnInit(){
Promise.all(this.items.map(itemname =>
this.api.get('ItemManager').getItem(itemname)
)).then(items => {
@@ -1,7 +1,5 @@
<h3>
{{tier}} items
</h3>
<itemselect
<itemselect
[character]="character"
[items]="allItems[tier]"
(onSelect)="onSelect.emit($event)"></itemselect>
(onSelect)="onSelect.emit($event)"></itemselect
>
@@ -10,7 +10,7 @@ import { _Tiers, allItems } from '../../../../../../backend/Types/Items';
selector: 'shop',
templateUrl: './shop.component.html',
})
export class FrontcraftShopComponent{
export class FrontcraftShopComponent implements OnInit{
@Input() character: Character
@Input() signup: Signup
@@ -22,5 +22,10 @@ export class FrontcraftShopComponent{
constructor(
private api: ApiService,
private dialogService : NbDialogService
){}
){
}
ngOnInit(){
}
}
@@ -0,0 +1,26 @@
import { Component, OnInit, ContentChild, AfterContentInit, ViewChild, AfterViewInit, Input, Output, EventEmitter } from '@angular/core';
import { ApiService as ApiService } from '../../services/login-api';
import { NbWindowService, NbWindowRef, NbToastrService, NbDialogService, NbDialogRef } from '@nebular/theme';
import { Item, Character, SRToken, Signup } from '../../../../../../backend/Types/Types';
import { _Tiers, allItems, Tiers } from '../../../../../../backend/Types/Items';
@Component({
selector: 'wowhead',
template: `
<a target="_blank" [href]="item.url">
<item [item]="item"></item>
</a>
`,
})
export class FrontcraftWowheadComponent implements OnInit{
@Input() item: Item
constructor(
private toastr: NbToastrService,
private api : ApiService
){}
async ngOnInit() {
}
}
@@ -6,7 +6,12 @@ accent="info">
<h2 style="text-transform: capitalize;">{{user.username}}</h2>
</nb-card-header>
<nb-card-body>
{{user.currency}}
{{user.MC}} MC
{{user.BWL}} BWL
{{user.ZG}} ZG
{{user.AQ20}} AQ20
{{user.AQ40}} AQ40
{{user.Naxx}} Naxx
<ng-container *ngFor="let char of characters">
<character [name]="char.charactername" [link]="'character'"></character>
</ng-container>
@@ -3,6 +3,7 @@ import { ApiService } from '../../services/login-api';
import { Router, ActivatedRoute } from '@angular/router';
import { User, Spec, Character } from '../../../../../../backend/Types/Types';
import { getClassColor } from '../../../../../../backend/Types/PlayerSpecs';
import { _Tiers } from '../../../../../../backend/Types/Items';
@Component({
selector: 'user-component',
@@ -28,7 +29,7 @@ export class FrontcraftUserComponent implements OnInit{
const characters = await this.api.get('CharacterManager').getCharactersOfUser(this.user.username)
characters.forEach(async c => {
const tokens = await this.api.get('ItemManager').getTokens(c)
const tokens = await this.api.get('ItemManager').getTokens(c, _Tiers, true)
c['tokens'] = tokens
c['color'] = getClassColor(c.class)
})
Binary file not shown.

After

Width:  |  Height:  |  Size: 29 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 33 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 34 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 30 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 33 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 366 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 36 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 32 KiB