Skip to content

Commit

Permalink
cultivation optimization
Browse files Browse the repository at this point in the history
  • Loading branch information
Lightczx committed Dec 22, 2022
1 parent bbc8324 commit a97bab8
Show file tree
Hide file tree
Showing 41 changed files with 763 additions and 279 deletions.
25 changes: 8 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,35 +1,26 @@
# Snap.Hutao
# [Snap.Hutao](https://hut.ao)
> 唷,找本堂主有何贵干呀?
![Snap.Hutao](https://repobeats.axiom.co/api/embed/f029553fbe0c60689b1710476ec8512452163fc9.svg)

## 项目首页(文档)
# 特别感谢

[![Deploy Docs](https://github.com/DGP-Studio/Snap.Hutao.Docs/actions/workflows/deploy-docs.yml/badge.svg)](https://github.com/DGP-Studio/Snap.Hutao.Docs/actions/workflows/deploy-docs.yml)
### 原神组织与个人

[HUT.AO](https://hut.ao)
* [HolographicHat](https://github.com/HolographicHat)
* [UIGF organization](https://uigf.org)

## 安装

* 前往 [下载页面](https://go.hut.ao/down) 下载最新版本的 `胡桃` 安装包
* (曾启用的可以跳过此步骤)在系统设置中打开 **开发者选项** 界面,勾选 `开发人员模式``允许 PowerShell 脚本`
* 完全解压后,右键使用 powershell 运行 `install.ps1` 文件
* 安装完成后可以关闭 `允许 PowerShell 脚本`

## 特别感谢

### 原神项目
### 特定的原神项目

* [biuuu/genshin-wish-export](https://github.com/biuuu/genshin-wish-export)
* [HolographicHat/YaeAchievement](https://github.com/HolographicHat/YaeAchievement)
* [HolographicHat/MiHoYoWebBridge](https://github.com/HolographicHat/MiHoYoWebBridge)
* [xunkong/xunkong](https://github.com/xunkong/xunkong)
* [YuehaiTeam/cocogoat](https://github.com/YuehaiTeam/cocogoat)

### 技术栈
### 使用的技术栈

* [CommunityToolkit/dotnet](https://github.com/CommunityToolkit/dotnet)
* [CommunityToolkit/WindowsCommunityToolkit](https://github.com/CommunityToolkit/WindowsCommunityToolkit)
* [dahall/taskscheduler](https://github.com/dahall/taskscheduler)
* [dotnet/efcore](https://github.com/dotnet/efcore)
* [dotnet/runtime](https://github.com/dotnet/runtime)
* [DotNetAnalyzers/StyleCopAnalyzers](https://github.com/DotNetAnalyzers/StyleCopAnalyzers)
Expand Down
4 changes: 4 additions & 0 deletions src/Snap.Hutao/Snap.Hutao/Factory/PickerFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@

using Snap.Hutao.Factory.Abstraction;
using Windows.Storage.Pickers;
using Windows.Win32;
using Windows.Win32.UI.Shell;
using WinRT;
using WinRT.Interop;

namespace Snap.Hutao.Factory;
Expand Down Expand Up @@ -37,6 +40,7 @@ public FileOpenPicker GetFileOpenPicker(PickerLocationId location, string commit
picker.FileTypeFilter.Add(type);
}

// https://github.com/microsoft/WindowsAppSDK/issues/2931
picker.FileTypeFilter.Add(AnyType);

return picker;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ public CultivateItem(Material inner, Entity.CultivateItem entity)
Inner = inner;
Entity = entity;
isFinished = Entity.IsFinished;
IsToday = CultivateItemHelper.IsTodaysMaterial(inner.Id, DateTimeOffset.Now);

FinishStateCommand = new RelayCommand(FlipIsFinished);
}
Expand Down Expand Up @@ -59,6 +60,11 @@ public bool IsFinished
}
}

/// <summary>
/// 是否为今日物品
/// </summary>
public bool IsToday { get; }

private void FlipIsFinished()
{
IsFinished = !IsFinished;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
// Copyright (c) DGP Studio. All rights reserved.
// Licensed under the MIT license.

namespace Snap.Hutao.Model.Binding.Cultivation;

/// <summary>
/// 养成物品帮助类
/// </summary>
public static class CultivateItemHelper
{
/// <summary>
/// 判断是否为当日物品
/// </summary>
/// <param name="itemId">材料Id</param>
/// <param name="now">时间</param>
/// <returns>是否为当日物品</returns>
public static bool IsTodaysMaterial(int itemId, DateTimeOffset now)
{
DateTimeOffset utcNow = now.ToUniversalTime();
utcNow = utcNow.AddHours(4);
DayOfWeek dayOfWeek = utcNow.DayOfWeek;

return dayOfWeek switch
{
DayOfWeek.Monday or DayOfWeek.Thursday => itemId switch
{
104301 or 104302 or 104303 => true, // 「自由」
104310 or 104311 or 104312 => true, // 「繁荣」
104320 or 104321 or 104322 => true, // 「浮世」
104329 or 104330 or 104331 => true, // 「诤言」
114001 or 114002 or 114003 or 114004 => true, // 高塔孤王
114013 or 114014 or 114015 or 114016 => true, // 孤云寒林
114025 or 114026 or 114027 or 114028 => true, // 远海夷地
114037 or 114038 or 114039 or 114040 => true, // 谧林涓露
_ => false,
},
DayOfWeek.Tuesday or DayOfWeek.Friday => itemId switch
{
104304 or 104305 or 104306 => true, // 「抗争」
104313 or 104314 or 104315 => true, // 「勤劳」
104323 or 104324 or 104325 => true, // 「风雅」
104332 or 104333 or 104334 => true, // 「巧思」
114005 or 114006 or 114007 or 114008 => true, // 凛风奔狼
114017 or 114018 or 114019 or 114020 => true, // 雾海云间
114029 or 114030 or 114031 or 114032 => true, // 鸣神御灵
114041 or 114042 or 114043 or 114044 => true, // 绿洲花园
_ => false,
},
DayOfWeek.Wednesday or DayOfWeek.Saturday => itemId switch
{
104307 or 104308 or 104309 => true, // 「诗文」
104316 or 104317 or 104318 => true, // 「黄金」
104326 or 104327 or 104328 => true, // 「天光」
104335 or 104336 or 104337 => true, // 「笃行」
114009 or 114010 or 114011 or 114012 => true, // 狮牙斗士
114021 or 114022 or 114023 or 114024 => true, // 漆黑陨铁
114033 or 114034 or 114035 or 114036 => true, // 今昔剧画
114045 or 114046 or 114047 or 114048 => true, // 谧林涓露
_ => false,
},
_ => false,
};
}
}
46 changes: 46 additions & 0 deletions src/Snap.Hutao/Snap.Hutao/Model/Binding/Hutao/CookBonusView.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
// Copyright (c) DGP Studio. All rights reserved.
// Licensed under the MIT license.

using Snap.Hutao.Model.Metadata;
using Snap.Hutao.Model.Metadata.Avatar;
using Snap.Hutao.Model.Primitive;

namespace Snap.Hutao.Model.Binding.Hutao;

/// <summary>
/// 料理奖励视图
/// </summary>
public class CookBonusView
{
/// <summary>
/// 原型
/// </summary>
public Material OriginItem { get; set; } = default!;

/// <summary>
/// 名称
/// </summary>
public Material Item { get; set; } = default!;

/// <summary>
/// 创建一个新的料理奖励视图
/// </summary>
/// <param name="cookBonus">料理奖励</param>
/// <param name="idMaterialMap">材料映射</param>
/// <returns>新的料理奖励视图</returns>
public static CookBonusView? Create(CookBonus? cookBonus, Dictionary<MaterialId, Material> idMaterialMap)
{
if (cookBonus == null)
{
return null;
}

CookBonusView view = new()
{
OriginItem = idMaterialMap[cookBonus.OriginItemId],
Item = idMaterialMap[cookBonus.ItemId],
};

return view;
}
}
56 changes: 0 additions & 56 deletions src/Snap.Hutao/Snap.Hutao/Model/InterChange/Inventory/UIIF.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,60 +31,4 @@ internal class UIIF
/// </summary>
[JsonPropertyName("list")]
public List<UIIFItem> List { get; set; } = default!;
}

/// <summary>
/// UIIF物品
/// </summary>
[JsonDerivedType(typeof(UIIFReliquary))]
[JsonDerivedType(typeof(UIIFWeapon))]
internal class UIIFItem
{
/// <summary>
/// 物品Id
/// </summary>
[JsonPropertyName("itemId")]
public int ItemId { get; set; }

/// <summary>
/// 物品Id
/// </summary>
[JsonPropertyName("count")]
public int Count { get; set; }
}

/// <summary>
/// UIIF圣遗物
/// </summary>
internal class UIIFReliquary : UIIFItem
{
/// <summary>
/// 物品Id
/// </summary>
[JsonPropertyName("level")]
public int Level { get; set; }

/// <summary>
/// 副属性列表
/// </summary>
[JsonPropertyName("appendPropIdList")]
public List<int> AppendPropIdList { get; set; } = default!;
}

/// <summary>
/// UIIF武器
/// </summary>
internal class UIIFWeapon : UIIFItem
{
/// <summary>
/// 物品Id
/// </summary>
[JsonPropertyName("level")]
public int Level { get; set; }

/// <summary>
/// 精炼等级 0-4
/// </summary>
[JsonPropertyName("promoteLevel")]
public int PromoteLevel { get; set; }
}
45 changes: 45 additions & 0 deletions src/Snap.Hutao/Snap.Hutao/Model/InterChange/Inventory/UIIFItem.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
// Copyright (c) DGP Studio. All rights reserved.
// Licensed under the MIT license.

using System.Collections.Immutable;

namespace Snap.Hutao.Model.InterChange.Inventory;

/// <summary>
/// UIIF物品
/// </summary>
internal class UIIFItem
{
/// <summary>
/// 物品Id
/// </summary>
[JsonPropertyName("itemId")]
public int ItemId { get; set; }

/// <summary>
/// 物品Id
/// </summary>
[JsonPropertyName("count")]
public int Count { get; set; }

/// <summary>
/// 等级
/// Reliquary/Weapon
/// </summary>
[JsonPropertyName("level")]
public int? Level { get; set; }

/// <summary>
/// 副属性列表
/// Reliquary
/// </summary>
[JsonPropertyName("appendPropIdList")]
public List<int>? AppendPropIdList { get; set; } = default!;

/// <summary>
/// 精炼等级 0-4
/// Weapon
/// </summary>
[JsonPropertyName("promoteLevel")]
public int? PromoteLevel { get; set; }
}
59 changes: 59 additions & 0 deletions src/Snap.Hutao/Snap.Hutao/Model/Intrinsic/MaterialType.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
// Copyright (c) DGP Studio. All rights reserved.
// Licensed under the MIT license.

namespace Snap.Hutao.Model.Intrinsic;

/// <summary>
/// 材料类型
/// </summary>
[SuppressMessage("", "SA1602")]
public enum MaterialType
{
MATERIAL_NONE = 0,
MATERIAL_FOOD = 1,
MATERIAL_QUEST = 2,
MATERIAL_EXCHANGE = 4,
MATERIAL_CONSUME,
MATERIAL_EXP_FRUIT,
MATERIAL_AVATAR,
MATERIAL_ADSORBATE,
MATERIAL_CRICKET,
MATERIAL_ELEM_CRYSTAL,
MATERIAL_WEAPON_EXP_STONE,
MATERIAL_CHEST,
MATERIAL_RELIQUARY_MATERIAL,
MATERIAL_AVATAR_MATERIAL,
MATERIAL_NOTICE_ADD_HP,
MATERIAL_SEA_LAMP,
MATERIAL_SELECTABLE_CHEST,
MATERIAL_FLYCLOAK,
MATERIAL_NAMECARD,
MATERIAL_TALENT,
MATERIAL_WIDGET,
MATERIAL_CHEST_BATCH_USE,
MATERIAL_FAKE_ABSORBATE,
MATERIAL_CONSUME_BATCH_USE,
MATERIAL_WOOD,
MATERIAL_FURNITURE_FORMULA = 27,
MATERIAL_CHANNELLER_SLAB_BUFF,
MATERIAL_FURNITURE_SUITE_FORMULA,
MATERIAL_COSTUME,
MATERIAL_HOME_SEED,
MATERIAL_FISH_BAIT,
MATERIAL_FISH_ROD,
MATERIAL_SUMO_BUFF, // never appear
MATERIAL_FIREWORKS,
MATERIAL_BGM,
MATERIAL_SPICE_FOOD,
MATERIAL_ACTIVITY_ROBOT,
MATERIAL_ACTIVITY_GEAR,
MATERIAL_ACTIVITY_JIGSAW,
MATERIAL_ARANARA,
MATERIAL_GCG_CARD,
MATERIAL_GCG_CARD_FACE, // 影幻卡面
MATERIAL_GCG_CARD_BACK,
MATERIAL_GCG_FIELD,
MATERIAL_DESHRET_MANUAL,
MATERIAL_RENAME_ITEM,
MATERIAL_GCG_EXCHANGE_ITEM,
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,17 @@ public partial class Avatar : IStatisticsItemSource, ISummaryItemSource, INameQu
[JsonIgnore]
public ComplexAvatarCollocation? Collocation { get; set; }

/// <summary>
/// [非元数据] 烹饪奖励
/// </summary>
[JsonIgnore]
public CookBonusView? CookBonusView { get; set; }

/// <summary>
/// 养成物品视图
/// </summary>
public List<Material>? CultivationItemsView { get; set; }

/// <inheritdoc/>
public ICalculableAvatar ToCalculable()
{
Expand Down
7 changes: 6 additions & 1 deletion src/Snap.Hutao/Snap.Hutao/Model/Metadata/Avatar/Avatar.cs
Original file line number Diff line number Diff line change
Expand Up @@ -81,5 +81,10 @@ public partial class Avatar
/// <summary>
/// 皮肤
/// </summary>
public IEnumerable<Costume> Costumes { get; set; } = default!;
public List<Costume> Costumes { get; set; } = default!;

/// <summary>
/// 养成物品
/// </summary>
public List<MaterialId> CultivationItems { get; set; } = default!;
}
Loading

0 comments on commit a97bab8

Please sign in to comment.