-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' of https://github.com/Encaik/wanjie
- Loading branch information
Showing
24 changed files
with
372 additions
and
105 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 22 additions & 23 deletions
45
src/app/components/reward-item-view/reward-item-view.component.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,22 @@ | ||
import { ComponentFixture, TestBed } from '@angular/core/testing'; | ||
|
||
import { RewardItemViewComponent } from './reward-item-view.component'; | ||
|
||
describe('RewardItemViewComponent', () => { | ||
let component: RewardItemViewComponent; | ||
let fixture: ComponentFixture<RewardItemViewComponent>; | ||
|
||
beforeEach(async () => { | ||
await TestBed.configureTestingModule({ | ||
imports: [RewardItemViewComponent] | ||
}) | ||
.compileComponents(); | ||
|
||
fixture = TestBed.createComponent(RewardItemViewComponent); | ||
component = fixture.componentInstance; | ||
fixture.detectChanges(); | ||
}); | ||
|
||
it('should create', () => { | ||
expect(component).toBeTruthy(); | ||
}); | ||
}); | ||
import { ComponentFixture, TestBed } from '@angular/core/testing'; | ||
|
||
import { RewardItemViewComponent } from './reward-item-view.component'; | ||
|
||
describe('RewardItemViewComponent', () => { | ||
let component: RewardItemViewComponent; | ||
let fixture: ComponentFixture<RewardItemViewComponent>; | ||
|
||
beforeEach(async () => { | ||
await TestBed.configureTestingModule({ | ||
imports: [RewardItemViewComponent] | ||
}).compileComponents(); | ||
|
||
fixture = TestBed.createComponent(RewardItemViewComponent); | ||
component = fixture.componentInstance; | ||
fixture.detectChanges(); | ||
}); | ||
|
||
it('should create', () => { | ||
expect(component).toBeTruthy(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,27 @@ | ||
<h5 nz-typography class="underline decoration-sky-500">任务面板</h5> | ||
<div class="flex-1 p-4 border-gray-300 border rounded overflow-auto"> </div> | ||
<div class="flex-1 p-4 border-gray-300 border rounded overflow-auto"> | ||
@if (currentTask) { | ||
<div class="h-full flex flex-col justify-between items-center"> | ||
<div class="gap-2 w-full"> | ||
<h5 nz-typography>{{ currentTask.title }}</h5> | ||
<p>任务描述:{{ currentTask.description }}</p> | ||
<p> | ||
任务奖励: | ||
@for (reward of currentTask.rewards; track $index) { | ||
<span class="mr-2">{{ ItemMap[reward.id].name }} * {{ reward.count }}</span> | ||
} | ||
</p> | ||
<p>完成情况:{{ currentTask.isCompleted ? '已完成' : '未完成' }}</p> | ||
</div> | ||
<div> | ||
@if (currentTask.isCompleted) { | ||
<button nz-button (click)="onGetRewardClick()">获得奖励</button> | ||
} | ||
</div> | ||
</div> | ||
} @else { | ||
<div class="w-full h-full flex justify-center items-center"> | ||
<nz-empty nzNotFoundContent="当前无任务"></nz-empty> | ||
</div> | ||
} | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,54 @@ | ||
import { Component } from '@angular/core'; | ||
import { Component, inject, OnInit } from '@angular/core'; | ||
import { NzButtonModule } from 'ng-zorro-antd/button'; | ||
import { NzEmptyModule } from 'ng-zorro-antd/empty'; | ||
import { NzTypographyModule } from 'ng-zorro-antd/typography'; | ||
|
||
import { getItemLevelClass, ItemMap, LogLevel, LogType, Task } from '../../../../models'; | ||
import { BackpackService } from '../../../../services/backpack.service'; | ||
import { LogService } from '../../../../services/log.service'; | ||
import { StatisticsService } from '../../../../services/statistics.service'; | ||
import { TaskService } from '../../../../services/task.service'; | ||
|
||
@Component({ | ||
selector: 'app-task', | ||
standalone: true, | ||
imports: [NzTypographyModule], | ||
imports: [NzTypographyModule, NzEmptyModule, NzButtonModule], | ||
templateUrl: './task.component.html' | ||
}) | ||
export class TaskComponent {} | ||
export class TaskComponent implements OnInit { | ||
private taskSrv = inject(TaskService); | ||
private statisticsService = inject(StatisticsService); | ||
private backpackSrv = inject(BackpackService); | ||
private logSrv = inject(LogService); | ||
currentTask: Task | undefined; | ||
ItemMap = ItemMap; | ||
|
||
ngOnInit(): void { | ||
this.taskSrv.task$.subscribe(task => (this.currentTask = task)); | ||
this.statisticsService.statistics$.subscribe(event => { | ||
if (!this.currentTask) return; | ||
this.currentTask.isCompleted = this.currentTask.conditions.every( | ||
condition => | ||
condition.type === event.type && | ||
condition.field === event.field && | ||
condition.count <= this.statisticsService.getValue(condition.type, condition.field) | ||
); | ||
}); | ||
} | ||
|
||
onGetRewardClick() { | ||
if (!this.currentTask) return; | ||
let msg: string = ''; | ||
this.currentTask.rewards.forEach(reward => { | ||
const item = ItemMap[reward.id]; | ||
this.backpackSrv.addItem(item, reward.count); | ||
msg += `<span class="${getItemLevelClass(item.level)}">${item.name}</span> * ${reward.count} `; | ||
}); | ||
this.logSrv.log({ | ||
msg: `完成任务,获得奖励:${msg}`, | ||
type: LogType.Item, | ||
level: LogLevel.Info | ||
}); | ||
this.currentTask && this.taskSrv.complatedTask(this.currentTask); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
<div class="h-full flex flex-col overflow-auto p-2 bg-white rounded shadow-md shadow-gray-200"> | ||
<div class="h-full flex flex-col overflow-auto gap-2 p-2 bg-white rounded shadow-md shadow-gray-200"> | ||
<app-log class="flex-1 flex flex-col overflow-auto" /> | ||
<app-task class="min-h-96 flex flex-col" /> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,11 @@ | ||
export * from './character.model'; | ||
export * from './env.model'; | ||
export * from './log.model'; | ||
export * from './buff.model'; | ||
export * from './battle.model'; | ||
export * from './challenge.model'; | ||
export * from './reward.model'; | ||
export * from './item.model'; | ||
export * from './battle.model'; // 战斗 | ||
export * from './buff.model'; // buff | ||
export * from './challenge.model'; // 副本 | ||
export * from './character.model'; // 角色 | ||
export * from './env.model'; // 环境 | ||
export * from './item.model'; // 物品 | ||
export * from './log.model'; // 日志 | ||
export * from './reward.model'; // 奖励池 | ||
export * from './runtime.model'; // 运行时 | ||
export * from './statistics.model'; // 统计 | ||
export * from './task.model'; // 任务 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import { Character } from './character.model'; | ||
import { Env } from './env.model'; | ||
import { BagItem } from './item.model'; | ||
import { Task } from './task.model'; | ||
|
||
export interface StorageData { | ||
runtimeData: { tick: number }; // 时间刻 | ||
characterData: Character; // 角色信息 | ||
envData: Env; // 环境信息 | ||
backpackData: BagItem[]; // 背包信息 | ||
taskData: string; // 任务信息 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
export interface CharacterStatistics { | ||
cultivationCount: number; | ||
} | ||
|
||
export interface StatisticsEvent { | ||
type: StatisticsEventType; | ||
field: string; | ||
count: number; | ||
} | ||
|
||
export enum StatisticsEventType { | ||
Character | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
import { inject } from '@angular/core'; | ||
|
||
import { StatisticsService } from '../services/statistics.service'; | ||
import { StatisticsEvent, StatisticsEventType } from './statistics.model'; | ||
|
||
export interface Task { | ||
id: number; | ||
nextId: number; | ||
title: string; | ||
description: string; | ||
rewards: TaskReward[]; | ||
isCompleted: boolean; | ||
conditions: StatisticsEvent[]; | ||
} | ||
|
||
export interface TaskReward { | ||
id: string; | ||
count: number; | ||
} | ||
|
||
export const TASKS: Record<string, Task> = { | ||
1: { | ||
id: 1, | ||
nextId: 2, | ||
title: '开始修炼', | ||
description: '点击开始修炼按钮,完成第一次修炼', | ||
rewards: [ | ||
{ | ||
id: '1', | ||
count: 100 | ||
} | ||
], | ||
isCompleted: false, | ||
conditions: [ | ||
{ | ||
type: StatisticsEventType.Character, | ||
field: 'cultivationCount', | ||
count: 1 | ||
} | ||
] | ||
}, | ||
2: { | ||
id: 2, | ||
nextId: 3, | ||
title: 'Task 2', | ||
description: 'This is the second task', | ||
rewards: [], | ||
isCompleted: false, | ||
conditions: [] | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 22 additions & 23 deletions
45
src/app/pages/challenge/pages/explore/explore.component.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,22 @@ | ||
import { ComponentFixture, TestBed } from '@angular/core/testing'; | ||
|
||
import { ExploreComponent } from './explore.component'; | ||
|
||
describe('ExploreComponent', () => { | ||
let component: ExploreComponent; | ||
let fixture: ComponentFixture<ExploreComponent>; | ||
|
||
beforeEach(async () => { | ||
await TestBed.configureTestingModule({ | ||
imports: [ExploreComponent] | ||
}) | ||
.compileComponents(); | ||
|
||
fixture = TestBed.createComponent(ExploreComponent); | ||
component = fixture.componentInstance; | ||
fixture.detectChanges(); | ||
}); | ||
|
||
it('should create', () => { | ||
expect(component).toBeTruthy(); | ||
}); | ||
}); | ||
import { ComponentFixture, TestBed } from '@angular/core/testing'; | ||
|
||
import { ExploreComponent } from './explore.component'; | ||
|
||
describe('ExploreComponent', () => { | ||
let component: ExploreComponent; | ||
let fixture: ComponentFixture<ExploreComponent>; | ||
|
||
beforeEach(async () => { | ||
await TestBed.configureTestingModule({ | ||
imports: [ExploreComponent] | ||
}).compileComponents(); | ||
|
||
fixture = TestBed.createComponent(ExploreComponent); | ||
component = fixture.componentInstance; | ||
fixture.detectChanges(); | ||
}); | ||
|
||
it('should create', () => { | ||
expect(component).toBeTruthy(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
:host { | ||
flex: 1; | ||
height: 0; | ||
overflow: auto; | ||
} |
Oops, something went wrong.
92112b7
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
wanjie – ./
wanjie.vercel.app
wanjie-git-main-encaiks-projects.vercel.app
wanjie-encaiks-projects.vercel.app