Skip to content

Commit

Permalink
feat: add support of smoke screen
Browse files Browse the repository at this point in the history
  • Loading branch information
KochiyaOcean committed Oct 11, 2023
1 parent d91d5ac commit 6c84ec9
Show file tree
Hide file tree
Showing 11 changed files with 48 additions and 6 deletions.
1 change: 1 addition & 0 deletions assets/i18n/en-US.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
"Compass Point": "Compass Point",
"Next Spot": "Next Spot",
"last_chosen": "Last chosen: ",
"smoke": "Smoke screen activated",
"A_rank": "A rank",
"Anchorage Repair": "Anchorage Repair",

Expand Down
1 change: 1 addition & 0 deletions assets/i18n/ja-JP.json
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@
"Show last chosen formation hint": "前の陣形選択を表示する",
"Ship parameters include equipment bonus": "装備込みのステータスを表示する",
"last_chosen": "前の選択:",
"smoke": "煙幕発動",
"Carrier Task Force": "空母機動部隊",
"Surface Task Force": "水上打撃部隊",
"Transport Escort": "輸送護衛部隊",
Expand Down
1 change: 1 addition & 0 deletions assets/i18n/ko-KR.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,5 +46,6 @@
"Item \"{{item}}:\" got! ": "「{{item}}」을(를) 얻었습니다!",
"Not in sortie": "출격중이 아닙니다",
"last_chosen": "Last chosen: ",
"smoke": "Smoke screen activated",
"A_rank": "A rank"
}
1 change: 1 addition & 0 deletions assets/i18n/zh-CN.json
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@
"Show last chosen formation hint": "提示上次战斗选择的阵型",
"Ship parameters include equipment bonus": "舰娘属性包含装备加成",
"last_chosen": "上次选择:",
"smoke": "烟幕发动",
"Carrier Task Force": "空母机动部队",
"Surface Task Force": "水上打击部队",
"Transport Escort": "输送护卫部队",
Expand Down
1 change: 1 addition & 0 deletions assets/i18n/zh-TW.json
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@
"Show last chosen formation hint": "提示上次戰鬥選擇的陣型",
"Ship parameters include equipment bonus": "艦娘屬性包含裝備加成",
"last_chosen": "上次選擇:",
"smoke": "煙幕發動",
"Carrier Task Force": "空母機動部隊",
"Surface Task Force": "水上打擊部隊",
"Transport Escort": "輸送護衛部隊",
Expand Down
6 changes: 5 additions & 1 deletion src/index.es
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ class ProphetBase extends Component {
eventKind: 0,
result: {},
battleForm: '', // api_formation[2]
smokeType: 0, // api_smoke_type
eFormation: '', // enemy formation, api_formation[1]
fFormation: '',
width: 500,
Expand Down Expand Up @@ -473,12 +474,13 @@ class ProphetBase extends Component {
const title = (packet.api_enemy_info || {}).api_deck_name
const { sortieMapId, currentNode } = sortie
const spot = `${sortieMapId}-${currentNode}`
const { fFormation } = this.state
const { fFormation, smokeType } = this.state
dispatch(
onBattleResult({
spot,
title,
fFormation,
smokeType,
}),
)
newState = this.handlePacketResult(this.battle)
Expand Down Expand Up @@ -540,6 +542,7 @@ class ProphetBase extends Component {
eFormation,
width,
height,
smokeType,
} = this.state

const { fleetIds, layout } = this.props
Expand Down Expand Up @@ -568,6 +571,7 @@ class ProphetBase extends Component {
fleetIds={fleetIds}
horizontalLayout={finalLayout === 'horizontal'}
root={this.root.current}
smokeType={smokeType}
/>
</Container>
)
Expand Down
6 changes: 4 additions & 2 deletions src/redux.es
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,12 @@ export const CACHE = do {
JSON.parse(item || '{}')
}

export const onBattleResult = ({ spot, fFormation, title }) => ({
export const onBattleResult = ({ spot, fFormation, title, smokeType }) => ({
type: '@@poi-plugin-prophet@updateHistory',
spot,
fFormation,
title,
smokeType,
})

export const onGetPracticeInfo = ({ title }) => ({
Expand All @@ -32,14 +33,15 @@ export const onLoadHistory = ({ history }) => ({
})

const HistoryReducer = (state = CACHE.history || {}, action) => {
const { type, spot, fFormation, title, history } = action
const { type, spot, fFormation, title, history, smokeType } = action
switch (type) {
case '@@poi-plugin-prophet@updateHistory':
return {
...state,
[spot]: {
fFormation,
title,
smokeType,
},
}
case '@@poi-plugin-prophet@updatePractice':
Expand Down
3 changes: 3 additions & 0 deletions src/utils/lib-battle-adapter.es
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,7 @@ export const synthesizeInfo = (_simulator, result, packets) => {
let fFormation = ''
let eFormation = ''
let battleForm = ''
let smokeType = 0
// assign mvp to specific ship
const [mainMvp, escortMvp] = result.mvp || [0, 0]
if (!(mainMvp < 0 || mainMvp > 6)) mainFleet[mainMvp].isMvp = true
Expand All @@ -238,6 +239,7 @@ export const synthesizeInfo = (_simulator, result, packets) => {
battleForm = (engagement || {}).engagement || ''
eFormation = (engagement || {}).eFormation || ''
fFormation = (engagement || {}).fFormation || ''
smokeType = (engagement || {}).smokeType || 0
}

if (aerial && type === StageType.Aerial) {
Expand Down Expand Up @@ -290,6 +292,7 @@ export const synthesizeInfo = (_simulator, result, packets) => {
battleForm,
eFormation,
fFormation,
smokeType,
result,
}
}
Expand Down
17 changes: 15 additions & 2 deletions src/views/battle-info.es
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,14 @@ const Container = styled.div`
const BATTLE_RESULT = ['SS', 'S', 'A', 'B', 'C', 'D', 'E']

const BattleInfo = withNamespaces('poi-plugin-prophet')(
({ result = '', eFormation = '', battleForm = '', airControl = '', t }) => (
({
result = '',
eFormation = '',
battleForm = '',
airControl = '',
smokeType = 0,
t,
}) => (
<Container>
<div>
{BATTLE_RESULT.includes(result) ? (
Expand All @@ -51,7 +58,12 @@ const BattleInfo = withNamespaces('poi-plugin-prophet')(
)}
</div>

{compact([_t(eFormation), _t(battleForm), _t(airControl)]).map((text) => (
{compact([
_t(eFormation),
_t(battleForm),
_t(airControl),
...(smokeType ? [`${t('smoke')}: ${smokeType}`] : []),
]).map((text) => (
<div key={text}>{text}</div>
))}
</Container>
Expand All @@ -63,6 +75,7 @@ BattleInfo.propTypes = {
eFormation: PropTypes.string,
battleForm: PropTypes.string,
airControl: PropTypes.string,
smokeType: PropTypes.number,
t: PropTypes.func.isRequired,
}

Expand Down
2 changes: 2 additions & 0 deletions src/views/battle-view-area.es
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,7 @@ const BattleViewArea = compose(
t,
horizontalLayout,
root,
smokeType,
}) => {
const View = isBaseDefense ? SquadView : ShipView
const times = !horizontalLayout ? 1 : 2
Expand Down Expand Up @@ -318,6 +319,7 @@ const BattleViewArea = compose(
eFormation={eFormation}
battleForm={battleForm}
airControl={airControl}
smokeType={smokeType}
/>
)
const mapInfo = (
Expand Down
15 changes: 14 additions & 1 deletion src/views/next-spot-info.es
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,13 @@ const NextSpotInfo = compose(
spot,
'fFormation',
]),
lastSmoke:
showLastFormation &&
get(extensionSelectorFactory(PLUGIN_KEY)(state), [
'history',
spot,
'smokeType',
]),
item,
}
}),
Expand All @@ -121,6 +128,7 @@ const NextSpotInfo = compose(
eventId,
eventKind,
lastFormation,
lastSmoke,
item,
t,
}) => {
Expand Down Expand Up @@ -188,7 +196,12 @@ const NextSpotInfo = compose(
{isHeavyBomberDefense && (
<SpotMessage>{t('Heavy Bomber Defense')}</SpotMessage>
)}
<div>{lastFormation && `${t('last_chosen')} ${_t(lastFormation)}`}</div>
<div>
{lastFormation &&
`${t('last_chosen')} ${_t(lastFormation)}${
lastSmoke ? ` (${t('smoke')})` : ''
}`}
</div>
</Container>
)
},
Expand Down

0 comments on commit 6c84ec9

Please sign in to comment.