refac: utilGame/getNPCColor

This commit is contained in:
2022-08-26 01:06:43 +09:00
parent 63771da876
commit 8a5a3b67f7
17 changed files with 52 additions and 30 deletions
+2 -2
View File
@@ -3,7 +3,7 @@
<div
class="bg1 nameHeader"
:style="{
color: getNpcColor(officer?.npcType ?? 0),
color: getNPCColor(officer?.npcType ?? 0),
textDecoration: isMe ? 'underline' : undefined,
}"
>
@@ -30,7 +30,7 @@
</div>
</template>
<script setup lang="ts">
import { getNpcColor } from "@/common_legacy";
import { getNPCColor } from "@/utilGame";
import type { ChiefResponse } from "@/defs/API/NationCommand";
import { mb_strwidth } from "@/util/mb_strwidth";
import type { PropType } from "vue";
+2 -2
View File
@@ -16,7 +16,7 @@
<div
class="col-7 align-self-center"
:style="{
color: getNpcColor(officer?.npcType ?? 0),
color: getNPCColor(officer?.npcType ?? 0),
}"
>
{{ officer?.name }}
@@ -64,7 +64,7 @@
</div>
</template>
<script setup lang="ts">
import { getNpcColor } from "@/common_legacy";
import { getNPCColor } from "@/utilGame";
import { formatTime } from "@/util/formatTime";
import { mb_strwidth } from "@/util/mb_strwidth";
import { parseTime } from "@/util/parseTime";
+2 -2
View File
@@ -22,7 +22,7 @@
<BFormSelectOption v-for="general of orderedGeneralList" :key="general.no" :value="general.no">
<span
:style="{
color: getNpcColor(general.npc),
color: getNPCColor(general.npc),
}"
>{{ general.officerLevel > 4 ? `*${general.name}*` : general.name }}({{ general.turntime.slice(-5) }}){{
textMap[orderBy][3](general)
@@ -87,7 +87,7 @@ import type { GeneralListItemP1 } from "./defs/API/Nation";
import { SammoAPI } from "./SammoAPI";
import { unwrap } from "@/util/unwrap";
import { merge2DArrToObjectArr } from "@/util/merge2DArrToObjectArr";
import { getNpcColor } from "@/common_legacy";
import { getNPCColor } from "@/utilGame";
import GeneralBasicCard from "./components/GeneralBasicCard.vue";
import GeneralSupplementCard from "@/components/GeneralSupplementCard.vue";
import type { NationStaticItem } from "./defs";
+3 -2
View File
@@ -3,7 +3,8 @@ import 'bootstrap';
import download from 'downloadjs';
import { unwrap } from "@util/unwrap";
import { isInteger } from 'lodash-es';
import { errUnknown, getNpcColor } from '@/common_legacy';
import { errUnknown } from '@/common_legacy';
import { getNPCColor } from './utilGame';
import { combineArray } from "@util/combineArray";
import { isBrightColor } from "@util/isBrightColor";
import { numberWithCommas } from "@util/numberWithCommas";
@@ -999,7 +1000,7 @@ $(function ($) {
for (const general of generalList) {
const $item = $(`<option value="${general.no}">${general.name}</option>`);
if (general.npc) {
$item.css('color', unwrap(getNpcColor(general.npc)));
$item.css('color', unwrap(getNPCColor(general.npc)));
} else {
$item.css('color', 'white');
}
+1 -1
View File
@@ -79,7 +79,7 @@ function br2nl (text) {
}
*/
export function getNpcColor(npcType: number): 'skyblue' | 'cyan' | 'deepskyblue' | 'darkcyan' | 'mediumaquamarine' | undefined {
export function getNPCColor(npcType: number): 'skyblue' | 'cyan' | 'deepskyblue' | 'darkcyan' | 'mediumaquamarine' | undefined {
if (npcType == 6){
return 'mediumaquamarine';
}
+3 -3
View File
@@ -5,7 +5,7 @@
<div
class="col-7 align-self-center"
:style="{
color: getNpcColor(officer.npcType ?? 0),
color: getNPCColor(officer.npcType ?? 0),
}"
>
{{ officer.name }}
@@ -16,7 +16,7 @@
<div class="d-grid mb-1 py-1 only500px bg1 center">
<div
:style="{
color: getNpcColor(officer.npcType ?? 0),
color: getNPCColor(officer.npcType ?? 0),
fontSize: '1.2em',
}"
>
@@ -271,7 +271,7 @@ import type { CommandItem, TurnObj } from "@/defs";
import { QueryActionHelper, type TurnObjWithTime } from "@/util/QueryActionHelper";
import type { Args } from "@/processing/args";
import type { StoredActionsHelper } from "@/util/StoredActionsHelper";
import { getNpcColor } from "@/common_legacy";
import { getNPCColor } from "@/utilGame";
import { BButton, BDropdownItem, BDropdownText, BButtonGroup, BDropdownDivider, BDropdown } from "bootstrap-vue-3";
import CommandSelectForm from "@/components/CommandSelectForm.vue";
import SimpleClock from "@/components/SimpleClock.vue";
+2 -2
View File
@@ -94,7 +94,7 @@ import type {
CellClickedEvent,
} from "ag-grid-community";
import { ProvidedColumnGroup } from "ag-grid-community";
import { getNpcColor } from "@/common_legacy";
import { getNPCColor } from "@/utilGame";
import type {
ValueGetterParams,
ValueFormatterFunc,
@@ -523,7 +523,7 @@ const columnRawDefs = ref<Partial<Record<headerType, GenColDef | GenColGroupDef>
cellStyle: (val: CellClassParams<GeneralListItem>) => {
const gen = unwrap(val.data);
const style: StyleValue = {
color: getNpcColor(gen.npc),
color: getNPCColor(gen.npc),
};
return style as CellStyle;
},
+2 -2
View File
@@ -2,7 +2,7 @@ import $ from 'jquery';
import { unwrap } from '@util/unwrap';
import axios from 'axios';
import { setAxiosXMLHttpRequest } from '@util/setAxiosXMLHttpRequest';
import { getNpcColor } from './common_legacy';
import { getNPCColor } from '@/utilGame';
declare const killturn: number;
declare const autorun_user: undefined|null|{
@@ -230,7 +230,7 @@ $(function () {
$obj.css('text-decoration', 'line-through');
+= 1;
}
const colorNPC = getNpcColor(val.NPC);
const colorNPC = getNPCColor(val.NPC);
if (colorNPC !== undefined) {
$obj.css('color', colorNPC);
}
+2 -2
View File
@@ -55,7 +55,7 @@ import {
type procNationItem,
type procNationList,
} from "../processingRes";
import { getNpcColor } from "@/common_legacy";
import { getNPCColor } from "@/utilGame";
const commandName = staticValues.commandName;
const searchable = getProcSearchable();
@@ -63,7 +63,7 @@ const generalList = ref<procGeneralList>([]);
const selectedGeneralID = ref(0);
function textHelpGeneral(gen: procGeneralItem): string {
const nameColor = getNpcColor(gen.npc);
const nameColor = getNPCColor(gen.npc);
const name = nameColor ? `<span style="color:${nameColor}">${gen.name}</span>` : gen.name;
return name;
}
+2 -2
View File
@@ -55,7 +55,7 @@ import {
type procGeneralKey,
type procGeneralRawItemList,
} from "../processingRes";
import { getNpcColor } from "@/common_legacy";
import { getNPCColor } from "@/utilGame";
const commandName = staticValues.commandName;
const searchable = getProcSearchable();
@@ -64,7 +64,7 @@ const generalList = convertGeneralList(procRes.generalsKey, procRes.generals);
const selectedGeneralID = ref(generalList[0].no);
function textHelpGeneral(gen: procGeneralItem): string {
const nameColor = getNpcColor(gen.npc);
const nameColor = getNPCColor(gen.npc);
const name = nameColor ? `<span style="color:${nameColor}">${gen.name}</span>` : gen.name;
return `${name} (${gen.leadership}/${gen.strength}/${gen.intel})`;
}
@@ -94,7 +94,7 @@ import {
type procNationItem,
type procNationList,
} from "../processingRes";
import { getNpcColor } from "@/common_legacy";
import { getNPCColor } from "@/utilGame";
import { isBrightColor } from "@/util/isBrightColor";
const commandName = staticValues.commandName;
@@ -106,7 +106,7 @@ const toggleZoom = ref(true);
const selectedGeneralID = ref(generalList[0].no);
function textHelpGeneral(gen: procGeneralItem): string {
const nameColor = getNpcColor(gen.npc);
const nameColor = getNPCColor(gen.npc);
const name = nameColor ? `<span style="color:${nameColor}">${gen.name}</span>` : gen.name;
return name;
}
+2 -2
View File
@@ -80,7 +80,7 @@ import {
type procGeneralRawItemList,
type procTroopList,
} from "../processingRes";
import { getNpcColor } from "@/common_legacy";
import { getNPCColor } from "@/utilGame";
import type { MapResult } from '@/defs';
import { SammoAPI } from '@/SammoAPI';
import { getGameConstStore, type GameConstStore } from '@/GameConstStore';
@@ -159,7 +159,7 @@ function textHelpGeneral(gen: procGeneralItem): string {
return `,<span style="text-decoration: underline;">${troopName}</span>`;
})();
const nameColor = getNpcColor(gen.npc);
const nameColor = getNPCColor(gen.npc);
const name = nameColor ? `<span style="color:${nameColor}">${gen.name}</span>` : gen.name;
return `${name} [${citiesMap.value.get(unwrap(gen.cityID))?.name}${troops}] (${gen.leadership}/${gen.strength}/${
gen.intel
+2 -2
View File
@@ -70,7 +70,7 @@ import {
type procGeneralKey,
type procGeneralRawItemList,
} from "./processingRes";
import { getNpcColor } from "@/common_legacy";
import { getNPCColor } from "@/utilGame";
const citiesMap = ref(new Map<
number,
@@ -90,7 +90,7 @@ const isGold = ref(true);
const selectedGeneralID = ref(generalList[0].no);
function textHelpGeneral(gen: procGeneralItem): string {
const nameColor = getNpcColor(gen.npc);
const nameColor = getNPCColor(gen.npc);
const name = nameColor ? `<span style="color:${nameColor}">${gen.name}</span>` : gen.name;
return `${name} (금${unwrap(gen.gold).toLocaleString()}/쌀${unwrap(gen.rice).toLocaleString()}) (${gen.leadership}/${
gen.strength
+2 -2
View File
@@ -40,7 +40,7 @@
</v-multiselect>
</template>
<script setup lang="ts">
import { getNpcColor } from "@/common_legacy";
import { getNPCColor } from "@/utilGame";
import { convertSearch초성 } from "@/util/convertSearch초성";
import { isBrightColor } from "@/util/isBrightColor";
import { unwrap } from "@/util/unwrap";
@@ -143,7 +143,7 @@ watch(
}
}
const nameColor = getNpcColor(gen.npc);
const nameColor = getNPCColor(gen.npc);
const name = nameColor ? `<span style="color:${nameColor}">${gen.name}</span>` : gen.name;
const searchText = convertSearch초성(gen.name);
+2 -2
View File
@@ -2,7 +2,7 @@ import axios from 'axios';
import { errUnknown } from '@/common_legacy';
import { getIconPath } from "@util/getIconPath";
import { TemplateEngine } from "@util/TemplateEngine";
import { getNpcColor } from '@/common_legacy';
import { getNPCColor } from "@/utilGame";
import type { GeneralListResponse, InvalidResponse, PublicGeneralItem } from '@/defs';
import { convertFormData } from '@util/convertFormData';
import { unwrap_any } from '@util/unwrap_any';
@@ -289,7 +289,7 @@ function printGeneralList(value: GeneralListResponse) {
if (general.reserved == 1) {
general.userCSS = 'color:violet';
} else if (general.npc > 0) {
general.userCSS = `color:${getNpcColor(general.npc)}`;
general.userCSS = `color:${getNPCColor(general.npc)}`;
}
if (general.ownerName) {
+20
View File
@@ -0,0 +1,20 @@
export function getNPCColor(
npcType: number
): "skyblue" | "cyan" | "deepskyblue" | "darkcyan" | "mediumaquamarine" | undefined {
if (npcType == 6) {
return "mediumaquamarine";
}
if (npcType == 5) {
return "darkcyan";
}
if (npcType == 4) {
return "deepskyblue";
}
if (npcType >= 2) {
return "cyan";
}
if (npcType == 1) {
return "skyblue";
}
return undefined;
}
+1
View File
@@ -9,6 +9,7 @@ export { formatInjury } from './formatInjury';
export { formatLog } from './formatLog';
export { formatOfficerLevelText } from './formatOfficerLevelText';
export { formatVoteColor } from "./formatVoteColor";
export { getNPCColor } from "./getNPCColor";
export { isValidObjKey } from "./isValidObjKey";
export { nextExpLevelRemain } from "./nextExpLevelRemain";
export { postFilterNationCommandGen } from "./postFilterNationCommandGen";