Browse Source

规划了等级构成,重新计划了升级所需的经验

master
hanqin 2 days ago
parent
commit
8e93ce1467
  1. 4
      Build_God_Admin_Frontend/Frontend/src/views/admin/LevelsView.vue
  2. 15
      Build_God_Admin_Frontend/Frontend/src/views/admin/PillsView.vue
  3. 20
      Build_God_Api/Build_God_Api/Services/CharacterService.cs
  4. 2
      Build_God_Api/Build_God_Api/Services/PillService.cs
  5. 6
      Build_God_Game/src/views/GameView.vue
  6. 4
      Build_God_Game/src/views/TrainingView.vue
  7. BIN
      Build_God_Game/模拟导图.xls

4
Build_God_Admin_Frontend/Frontend/src/views/admin/LevelsView.vue

@ -64,10 +64,6 @@ const closeDialog = () => {
}
const saveLevel = async () => {
if (!formData.value.name || !formData.value.currentLevelMinExp || !formData.value.levelId) {
ElMessage.error('请填写必填项')
return
}
if (isEditing.value) {
if (formData.value !== undefined) {

15
Build_God_Admin_Frontend/Frontend/src/views/admin/PillsView.vue

@ -57,6 +57,7 @@ const translateRarity = (id: number) => {
}
const translateLevel = (id: number) => {
console.log(levels)
var item = levels.value.find(x => x.levelId == id);
if (item) {
return item.name
@ -90,18 +91,6 @@ const closeDialog = () => {
}
const savePill = async () => {
console.log('formdata', formData.value)
if (!formData.value.name
|| !formData.value.type
|| !formData.value.rarity
|| !formData.value.money
|| !formData.value.description
|| !formData.value.requirdLevelId
|| !formData.value.effectValue
|| !formData.value.duration) {
ElMessage.error('请填写必填项')
return
}
if (isEditing.value) {
const index = pills.value.findIndex(p => p.id === formData.value.id)
@ -262,7 +251,7 @@ const fetchLevels = async () => {
</el-form-item>
<el-form-item label="需求等级">
<el-select v-model="formData.requirdLevelId">
<el-option v-for="(value, index) in levels" :key="index" :value="value.id" :label="value.name">
<el-option v-for="(value, index) in levels" :key="index" :value="value.levelId" :label="value.name">
</el-option>
</el-select>
</el-form-item>

20
Build_God_Api/Build_God_Api/Services/CharacterService.cs

@ -7,7 +7,7 @@ using static Build_God_Api.DB.BagItem;
namespace Build_God_Api.Services
{
public interface ICharacterService
public interface ICharacterService
{
public Task<Character?> GetCharacterByAccountId(int accountId);
public Task<List<Character>> GetCharactersByAccountId(int accountId);
@ -153,16 +153,16 @@ public interface ICharacterService
}
var duration = DateTime.Now - character.TrainingOn.Value;
var seconds = (decimal)duration.TotalSeconds;
var seconds = duration.TotalSeconds;
// exp = 0.1 * seconds * level * level * (1 + buff)
var expGained = 0.01m * seconds * character.LevelId * character.LevelId * (1 + 0);
character.CurrentExp += Math.Round(expGained);
// exp = 0.02 * seconds * level^1.5 * (1 + buff)
var expGained = Convert.ToDecimal(0.02 * seconds * Math.Pow(character.LevelId, 1.5) * (1 + 0));
var result = Math.Round(expGained);
character.CurrentExp += result;
character.TrainingOn = null;
await db.Updateable(character).ExecuteCommandAsync();
return expGained;
return result;
}
private readonly RandomNumberGenerator _rng = RandomNumberGenerator.Create();
@ -211,7 +211,7 @@ public interface ICharacterService
return await db.Queryable<Character>().AnyAsync(x => x.Name == name);
}
public async Task<Character?> GetCharacterByAccountId(int accountId)
public async Task<Character?> GetCharacterByAccountId(int accountId)
{
return await db.Queryable<Character>().FirstAsync(x => x.AccountId == accountId && x.isLocked == false);
}
@ -291,7 +291,7 @@ public async Task<Character?> GetCharacterByAccountId(int accountId)
NextLevelRequiredPillId = nextLevelRequiredPillId,
NextLevelRequiredPillName = nextLevelRequiredPillName,
NextLevelRequiredPillQuantity = nextLevelRequiredPillQuantity,
TrainingExpRate = 0.01m,
TrainingExpRate = 0.02m,
LastLogin = c.LastLogin,
CreatedOn = c.CreatedOn
});
@ -331,7 +331,7 @@ public async Task<Character?> GetCharacterByAccountId(int accountId)
Name = character.Name,
AccountId = currentUserService.UserId,
CurrentExp = 0,
LevelId = 1,
LevelId = 10,
Money = 0,
CurrentHP = 100,
ProfessionId = character.ProfessionId,

2
Build_God_Api/Build_God_Api/Services/PillService.cs

@ -48,7 +48,7 @@ namespace Build_God_Api.Services
public async Task<List<Pill>> GetAll()
{
return await db.Queryable<Pill>().ToListAsync();
return await db.Queryable<Pill>().OrderBy(x=>x.RequirdLevelId).ToListAsync();
}
public async Task<bool> Update(Pill item)

6
Build_God_Game/src/views/GameView.vue

@ -87,7 +87,7 @@ const handleBreakthrough = async () => {
<StarBorder
as="div"
color="#22c55e"
speed="6s"
speed="5s"
:thickness="2"
style="display: block; width: 100%; max-width: 480px;"
>
@ -106,7 +106,7 @@ const handleBreakthrough = async () => {
</div>
<div class="menu-grid">
<GlareHover v-for="item in menuItems" :key="item.label" width="100%" height="120px"
<GlareHover v-for="item in menuItems" :key="item.label" width="100%" height="100px"
:background="item.isTraining ? 'rgba(255,136,68,0.1)' : 'rgba(255,255,255,0.02)'" border-radius="16px"
:border-color="item.isTraining ? 'rgba(255,136,68,0.3)' : 'rgba(255,255,255,0.08)'"
:glare-color="item.isTraining ? '#ff8844' : '#ffffff'" :glare-opacity="0.1" class="menu-card"
@ -251,7 +251,7 @@ const handleBreakthrough = async () => {
.menu-grid {
display: grid;
grid-template-columns: repeat(3, 1fr);
grid-template-columns: repeat(4, 1fr);
gap: 16px;
margin-bottom: 32px;
}

4
Build_God_Game/src/views/TrainingView.vue

@ -21,11 +21,9 @@ const showMsg = (text: string, type: 'success' | 'error' = 'success') => {
const trainingStartTime = ref<Date | null>(null)
const elapsedSeconds = ref(0)
const levelId = computed(() => characterStore.currentCharacter?.levelId ?? 1)
const trainingExpRate = computed(() => characterStore.currentCharacter?.trainingExpRate ?? 0.01)
const expectedExp = computed(() => {
const rate = trainingExpRate.value
const level = levelId.value
return Math.floor(elapsedSeconds.value * rate * level * level)
return Math.floor(0.02 * elapsedSeconds.value * Math.pow(level, 1.5))
})
const isTraining = computed(() => !!trainingStartTime.value)
let timer: number | null = null

BIN
Build_God_Game/模拟导图.xls

Binary file not shown.
Loading…
Cancel
Save