forked from xivanalysis/xivanalysis
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Rotation.tsx
81 lines (69 loc) · 1.91 KB
/
Rotation.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
import cn from 'classnames'
import {ActionLink, ItemLink} from 'components/ui/DbLink'
import {getDataBy} from 'data'
import ACTIONS, {ITEM_ID_OFFSET} from 'data/ACTIONS'
import {Cause} from 'event'
import {Ability} from 'fflogs'
import React, {Component} from 'react'
import overlayStyle from './Procs/ProcOverlay.module.css'
import styles from './Rotation.module.css'
export interface RotationEvent {
ability?: Ability,
cause?: Cause,
action?: number
isProc?: boolean
}
interface RotationProps {
events: RotationEvent[]
}
export default class Rotation extends Component<RotationProps> {
getActionId(event: RotationEvent): number | undefined {
if (event.action != null) {
return event.action
}
if (event.ability != null) {
return event.ability.guid
}
if (event.cause != null && event.cause.type === 'action') {
return event.cause.action
}
return undefined
}
override render() {
const {events} = this.props
return <div className={styles.container}>
{events.map((event, index) => {
const actionId = this.getActionId(event)
const action = getDataBy(ACTIONS, 'id', actionId) as TODO
// Don't bother showing the icon for autos
if (!action || action.autoAttack) {
return
}
// Stuff like the duty action doesn't have an icon mapping yet.
// TODO: Sort this out if it's a problem
if (!action.icon) {
console.error(event, 'event ability has no icon')
return false
}
const linkClassName = [
styles.link,
{[styles.ogcd]: !action.onGcd},
event.isProc ? overlayStyle.procOverlay : '',
]
const iconSize = action.onGcd ? styles.gcdSize : styles.ogcdSize
const isItem = action.id >= ITEM_ID_OFFSET
const Link = isItem ? ItemLink : ActionLink
return <div
key={index}
className={cn(...linkClassName)}
>
<Link
showName={false}
iconSize={iconSize}
{...action}
/>
</div>
})}
</div>
}
}