<?php

/**
 * 盲盒内容
 */

namespace Tool\LoadTemplate\Logic;

use Game\Constant\ConstTemplate\TemplateBlindBox;
use Tool\LoadTemplate\ILogic;

class BlindBoxLogic extends ILogic
{
    public function dealRow(&$row): bool
    {
        //初始数据
        for ($i = TemplateBlindBox::START_NUM; $i <= TemplateBlindBox::END_NUM; $i++) {
            $row[TemplateBlindBox::ITEM_KEY.$i] = 0;
            $row[TemplateBlindBox::ITEM_NUM.$i] = 0;
            $row[TemplateBlindBox::PR_KEY.$i] = 0;
        }

        $itemArr = explode(";", $row[TemplateBlindBox::Item]);
        $i = 1;
        foreach ($itemArr as $idx => $itemStr) {
            $item = explode("*", $itemStr);
            [$itemId, $num, $pr] = $item;
            $row[TemplateBlindBox::ITEM_KEY.$i] = (int)$itemId;
            $row[TemplateBlindBox::ITEM_NUM.$i] = (int)$num;
            $row[TemplateBlindBox::PR_KEY.$i] = (int)$pr;
            $i++;
        }
        $row[TemplateBlindBox::IsOnly] = (int)$row[TemplateBlindBox::IsOnly];
        return true;
    }
}
