写了个饥荒食谱速查工具 - V2EX
V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
爱意满满的作品展示区。
imba97
V2EX    分享创造

写了个饥荒食谱速查工具

  •  
  •   imba97
    imba97 249 天前 3072 次点击
    这是一个创建于 249 天前的主题,其中的信息可能已经有所发展或是发生改变。

    使用

    项目地址:https://dst-recipe.netlify.app

    基本搜索

    在下方输入框中输入关键字,可以是名称、拼音、拼音首字母

    展示食材基本信息、制作必须食材和条件

    多个结果

    多个结果可以滑动查看

    代码分析

    逻辑上来说是分为两块,一个是食材,一个是食谱

    食材

    每种食材有不同的属性,比如肉度、怪物度、鱼度等等

    所以就需要一个基类来表示食材

    export abstract class IngredientBase extends InstanceClass { protected abstract _name: string /** * 肉度 */ protected _meat?: number /** * 怪物度 */ protected _monster?: number /** * 鱼度 */ protected _fish?: number // ... } 

    实现类

    import icon from '~/assets/images/ingredients/monster-meat.png' import { IngredientBase } from '~/composables/ingredient/ingredientBaseClass' export default class MonsterMeat extends IngredientBase { protected _name = '怪物肉' protected _image = icon protected override _meat = 1 protected override _mOnster= 1 } 

    食谱

    每种食谱有不同的制作条件,比如所需食材、属性度条件等等

    实现方式也相同

    export abstract class FoodBase extends InstanceClass { private _pinyin: string = '' private _pinyinInitials: string = '' protected abstract _name: string protected abstract _health: number protected abstract _hunger: number protected abstract _sanity: number protected abstract _rot: number protected abstract _cooking: number protected abstract _priority: number protected abstract _image: string /** * 合并条件 */ protected _merge: IngredientTypeKey[][] = [] /** * 所需食材 */ protected _ingredientsCondition: IngredientsCOndition= [] /** * 仅限沃利 */ protected _warlyOnly: boolean = false /** * 所需肉度 */ protected _meat?: ComparisonOperator /** * 所需怪物度 */ protected _monster?: ComparisonOperator /** * 所需怪物度 */ protected _monster?: ComparisonOperator // ... } 

    除了所需属性度之外,还有一些其他配置,例如 _merge,可以表示某几个属性度任意一个满足即可

    比如火鸡正餐

    import type { IngredientTypeKey } from '~/enums/ingredientType' import type { ComparisonOperator } from '~/types/comparisonOperator' import type { IngredientsCondition } from '~/types/ingredientsCondition' import icon from '~/assets/images/foods/turkey-dinner.png' import { FoodBase } from '~/composables/food/foodBaseClass' import Drumstick from '~/ingredients/drumstick' export default class TurkeyDinner extends FoodBase { _name = '火鸡正餐' _health = 20 _hunger = 75 _sanity = 5 _rot = 6 _cooking = 60 _priority = 10 _image = icon protected override _ingredientsCondition: IngredientsCOndition= [ { ingredients: [ Drumstick ], condition: { ge: 2 } } ] protected override _merge: IngredientTypeKey[][] = [ ['vegetable', 'fruit'] ] protected override _meat: ComparisOnOperator= { gt: 1 } protected override _vegetable: ComparisOnOperator= { ge: 0.5 } protected override _fruit: ComparisOnOperator= { gt: 0 } } 

    会显示为这样

    _ingredientsCondition 是所需食材,有时也需要表示某几种食材满足一种即可

    比如发光浆果慕斯

    import type { ComparisonOperator } from '~/types/comparisonOperator' import type { IngredientsCondition } from '~/types/ingredientsCondition' import icon from '~/assets/images/foods/glow-berry-mousse.png' import { FoodBase } from '~/composables/food/foodBaseClass' import GlowBerry from '~/ingredients/glowBerry' import LesserGlowBerry from '~/ingredients/lesserGlowBerry' export default class GlowBerryMousse extends FoodBase { _name = '发光浆果慕斯' _health = 3 _hunger = 37.5 _sanity = 10 _rot = 8 _cooking = 20 _priority = 30 _image = icon protected override _ingredientsCondition: IngredientsCOndition= [ [ { ingredients: [ GlowBerry ], condition: { ge: 1 } }, { ingredients: [ LesserGlowBerry ], condition: { ge: 2 } } ] ] protected override _fish: ComparisOnOperator= { ge: 1 } protected override _notEdible: ComparisOnOperator= { eq: 0 } protected override _warlyOnly= true } 

    会显示为这样

    开源

    imba97/dst-recipe

    数据来源

    饥荒中文维基-烹饪

    11 条回复    2025-02-08 17:37:10 +08:00
    wegbjwjm
        1
    wegbjwjm  
       249 天前 via iPhone
    玩了几年了,还是会被狗咬死,被牛顶死,被 boss 踩死
    dobelee
        2
    dobelee  
       249 天前
    @wegbjwjm 宫崎英高直呼内行。
    imba97
        3
    imba97  
    OP
       249 天前
    @wegbjwjm 最近刚开始玩,也是 kuku 死
    VampireDemon
        4
    VampireDemon  
       248 天前
    一个 mode 解决所有问题
    imba97
        5
    imba97  
    OP
       248 天前
    @VampireDemon 也用 mode ,不过食谱 mode 好像只能通过不断放食材才能缩小范围,不然很多不好找
    xfXqz1417LakqH82
        6
    xfXqz1417LakqH82  
       248 天前
    这玩意还是跟朋友联机开挂好玩
    youngitachi
        7
    youngitachi  
       248 天前
    又想起了当年和同学在宿舍玩饥荒的日子啊,一转眼都毕业 6 年多了
    imba97
        8
    imba97  
    OP
       248 天前
    @CaCo6 确实,但开挂是啥
    imba97
        9
    imba97  
    OP
       248 天前
    @youngitachi 我那时候是狙击手幽灵战士,局域网联机,找人找一通宵
    xfXqz1417LakqH82
        10
    xfXqz1417LakqH82  
       247 天前
    @imba97 一行上帝代码 无限资源 想要啥直接点就行 都是解锁的
    imba97
        11
    imba97  
    OP
       247 天前
    @CaCo6 哦哦,倒是知道有各种指令,目前还是老老实实开荒啥的
    关于     帮助文档     自助推广系统     博客     API     FAQ     Solana     919 人在线   最高记录 6679       Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 27ms UTC 20:51 PVG 04:51 LAX 13:51 JFK 16:51
    Do have faith in what you're doing.
    ubao snddm index pchome yahoo rakuten mypaper meadowduck bidyahoo youbao zxmzxm asda bnvcg cvbfg dfscv mmhjk xxddc yybgb zznbn ccubao uaitu acv GXCV ET GDG YH FG BCVB FJFH CBRE CBC GDG ET54 WRWR RWER WREW WRWER RWER SDG EW SF DSFSF fbbs ubao fhd dfg ewr dg df ewwr ewwr et ruyut utut dfg fgd gdfgt etg dfgt dfgd ert4 gd fgg wr 235 wer3 we vsdf sdf gdf ert xcv sdf rwer hfd dfg cvb rwf afb dfh jgh bmn lgh rty gfds cxv xcv xcs vdas fdf fgd cv sdf tert sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf shasha9178 shasha9178 shasha9178 shasha9178 shasha9178 liflif2 liflif2 liflif2 liflif2 liflif2 liblib3 liblib3 liblib3 liblib3 liblib3 zhazha444 zhazha444 zhazha444 zhazha444 zhazha444 dende5 dende denden denden2 denden21 fenfen9 fenf619 fen619 fenfe9 fe619 sdf sdf sdf sdf sdf zhazh90 zhazh0 zhaa50 zha90 zh590 zho zhoz zhozh zhozho zhozho2 lislis lls95 lili95 lils5 liss9 sdf0ty987 sdft876 sdft9876 sdf09876 sd0t9876 sdf0ty98 sdf0976 sdf0ty986 sdf0ty96 sdf0t76 sdf0876 df0ty98 sf0t876 sd0ty76 sdy76 sdf76 sdf0t76 sdf0ty9 sdf0ty98 sdf0ty987 sdf0ty98 sdf6676 sdf876 sd876 sd876 sdf6 sdf6 sdf9876 sdf0t sdf06 sdf0ty9776 sdf0ty9776 sdf0ty76 sdf8876 sdf0t sd6 sdf06 s688876 sd688 sdf86