Fixin things
This commit is contained in:
@@ -393,11 +393,17 @@ public class CraftingHandler
|
|||||||
};
|
};
|
||||||
|
|
||||||
// Calculate skill quality bonus
|
// Calculate skill quality bonus
|
||||||
// 2x required level = 50% chance for max on each roll
|
// Formula creates a curve where you need to significantly overlevel the recipe to get perfect rolls
|
||||||
// Formula: skillBonus = min(1.0, skill.Level / (recipe.RequiredLevel * 2))
|
// At required level: ~10% chance for max
|
||||||
float skillBonus = Math.Min(1.0f, (float)skill.Level / (recipe.RequiredLevel * 2));
|
// At 2x required level: ~40% chance
|
||||||
_log.LogInformation("Skill bonus: {SkillBonus} (level {Level} / required {Required})",
|
// At 4x required level: ~75% chance
|
||||||
skillBonus, skill.Level, recipe.RequiredLevel);
|
// At 10x required level: ~95% chance
|
||||||
|
float levelRatio = (float)skill.Level / Math.Max(1, recipe.RequiredLevel);
|
||||||
|
float skillBonus = Math.Min(0.95f, (levelRatio - 1f) / 10f); // Caps at 95% to keep some RNG
|
||||||
|
skillBonus = Math.Max(0.05f, skillBonus); // Minimum 5% chance
|
||||||
|
|
||||||
|
_log.LogInformation("Skill bonus: {SkillBonus:F2} (level {Level} / required {Required}, ratio {Ratio:F2})",
|
||||||
|
skillBonus, skill.Level, recipe.RequiredLevel, levelRatio);
|
||||||
|
|
||||||
int totalRolled = 0;
|
int totalRolled = 0;
|
||||||
int maxPossibleTotal = 0;
|
int maxPossibleTotal = 0;
|
||||||
@@ -505,21 +511,11 @@ public class CraftingHandler
|
|||||||
Quantity = finalOutputQuantity,
|
Quantity = finalOutputQuantity,
|
||||||
SlotIndex = emptySlot,
|
SlotIndex = emptySlot,
|
||||||
IsEquipped = false,
|
IsEquipped = false,
|
||||||
AcquiredAt = DateTime.UtcNow
|
AcquiredAt = DateTime.UtcNow,
|
||||||
|
CraftedItem = craftedItem // Link the crafted item directly
|
||||||
};
|
};
|
||||||
db.DungeonCharacterItems.Add(newItem);
|
db.DungeonCharacterItems.Add(newItem);
|
||||||
finalSlotIndex = emptySlot;
|
finalSlotIndex = emptySlot;
|
||||||
|
|
||||||
// Link crafted item if applicable
|
|
||||||
if (craftedItem != null)
|
|
||||||
{
|
|
||||||
await db.SaveChangesAsync(); // Save to get newItem.Id
|
|
||||||
db.DungeonCharacterItemCraftedLinks.Add(new DungeonCharacterItemCraftedLink
|
|
||||||
{
|
|
||||||
CharacterItemId = newItem.Id,
|
|
||||||
CraftedItemId = craftedItem.Id
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+3094
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,48 @@
|
|||||||
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
|
|
||||||
|
#nullable disable
|
||||||
|
|
||||||
|
namespace SystemRevivalServer.Migrations
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
public partial class CraftingFix : Migration
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void Up(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.AddColumn<ulong>(
|
||||||
|
name: "CraftedItemId",
|
||||||
|
table: "dungeon_character_items",
|
||||||
|
type: "bigint unsigned",
|
||||||
|
nullable: true);
|
||||||
|
|
||||||
|
migrationBuilder.CreateIndex(
|
||||||
|
name: "IX_dungeon_character_items_CraftedItemId",
|
||||||
|
table: "dungeon_character_items",
|
||||||
|
column: "CraftedItemId");
|
||||||
|
|
||||||
|
migrationBuilder.AddForeignKey(
|
||||||
|
name: "FK_dungeon_character_items_dungeon_crafted_items_CraftedItemId",
|
||||||
|
table: "dungeon_character_items",
|
||||||
|
column: "CraftedItemId",
|
||||||
|
principalTable: "dungeon_crafted_items",
|
||||||
|
principalColumn: "Id");
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void Down(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.DropForeignKey(
|
||||||
|
name: "FK_dungeon_character_items_dungeon_crafted_items_CraftedItemId",
|
||||||
|
table: "dungeon_character_items");
|
||||||
|
|
||||||
|
migrationBuilder.DropIndex(
|
||||||
|
name: "IX_dungeon_character_items_CraftedItemId",
|
||||||
|
table: "dungeon_character_items");
|
||||||
|
|
||||||
|
migrationBuilder.DropColumn(
|
||||||
|
name: "CraftedItemId",
|
||||||
|
table: "dungeon_character_items");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -537,6 +537,9 @@ namespace SystemRevivalServer.Migrations
|
|||||||
b.Property<ulong>("CharacterId")
|
b.Property<ulong>("CharacterId")
|
||||||
.HasColumnType("bigint unsigned");
|
.HasColumnType("bigint unsigned");
|
||||||
|
|
||||||
|
b.Property<ulong?>("CraftedItemId")
|
||||||
|
.HasColumnType("bigint unsigned");
|
||||||
|
|
||||||
b.Property<int?>("EquipSlot")
|
b.Property<int?>("EquipSlot")
|
||||||
.HasColumnType("int");
|
.HasColumnType("int");
|
||||||
|
|
||||||
@@ -556,6 +559,8 @@ namespace SystemRevivalServer.Migrations
|
|||||||
|
|
||||||
b.HasIndex("CharacterId");
|
b.HasIndex("CharacterId");
|
||||||
|
|
||||||
|
b.HasIndex("CraftedItemId");
|
||||||
|
|
||||||
b.HasIndex("ItemDefinitionId");
|
b.HasIndex("ItemDefinitionId");
|
||||||
|
|
||||||
b.ToTable("dungeon_character_items");
|
b.ToTable("dungeon_character_items");
|
||||||
@@ -2714,6 +2719,10 @@ namespace SystemRevivalServer.Migrations
|
|||||||
.OnDelete(DeleteBehavior.Cascade)
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
.IsRequired();
|
.IsRequired();
|
||||||
|
|
||||||
|
b.HasOne("DataServer.Data.Entities.DungeonCraftedItem", "CraftedItem")
|
||||||
|
.WithMany()
|
||||||
|
.HasForeignKey("CraftedItemId");
|
||||||
|
|
||||||
b.HasOne("DataServer.Data.Entities.DungeonItemDefinition", "ItemDefinition")
|
b.HasOne("DataServer.Data.Entities.DungeonItemDefinition", "ItemDefinition")
|
||||||
.WithMany()
|
.WithMany()
|
||||||
.HasForeignKey("ItemDefinitionId")
|
.HasForeignKey("ItemDefinitionId")
|
||||||
@@ -2722,6 +2731,8 @@ namespace SystemRevivalServer.Migrations
|
|||||||
|
|
||||||
b.Navigation("Character");
|
b.Navigation("Character");
|
||||||
|
|
||||||
|
b.Navigation("CraftedItem");
|
||||||
|
|
||||||
b.Navigation("ItemDefinition");
|
b.Navigation("ItemDefinition");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -59,6 +59,7 @@ public class CharacterModel : AdminPageModel
|
|||||||
{
|
{
|
||||||
var allItems = await _db.DungeonCharacterItems
|
var allItems = await _db.DungeonCharacterItems
|
||||||
.Include(i => i.ItemDefinition)
|
.Include(i => i.ItemDefinition)
|
||||||
|
.Include(i => i.CraftedItem)
|
||||||
.Where(i => i.CharacterId == Character.Id)
|
.Where(i => i.CharacterId == Character.Id)
|
||||||
.ToListAsync();
|
.ToListAsync();
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user